Ind.ie is now Small Technology Foundation.
Commit ca0d03d8 authored by Aral Balkan's avatar Aral Balkan

Set now renders the doctype properly (added test for HTML5). Updated JSDOM to...

Set now renders the doctype properly (added test for HTML5). Updated JSDOM to the latest 3.x branch version. Raised version to 1.0.1
parent 6c06d228
......@@ -123,6 +123,19 @@ render = (template, data) ->
html = window.document.documentElement.outerHTML;
# Note: .outerHTML does not return the doctype, get it manually.
# (Adapted from http://stackoverflow.com/a/10162353/253485 by Rob W)
doctype = window.document.doctype;
if doctype != null
doctypeName = doctype.name
doctypePublicID = (doctype.publicId ? ' PUBLIC "' + doctype.publicId + '"' : '')
doctypePublicAndSystemID = (!doctype.publicId && doctype.systemId ? ' SYSTEM' : '')
doctypeSystemID = (doctype.systemId ? ' "' + doctype.systemId + '"' : '')
doctypeHTML = "<!DOCTYPE #{doctypeName}#{doctypePublicID}#{doctypePublicAndSystemID}#{doctypeSystemID}>"
# Add the doctype to the top of the rest of the HTML
html = "#{doctypeHTML}#{html}"
return html
exports.render = render
{
"name": "indie-set",
"description": "Set is an unobtrusive and DRY template engine for Node.js and browsers.",
"version": "1.0.0",
"version": "1.0.1",
"author": "Aral Balkan <aral@ind.ie>",
"repository": {
"type": "git",
......@@ -17,7 +17,7 @@
"express": "4.9.7",
"forever": "0.11.1",
"ghm": "1.0.0-3",
"jsdom": "3.1.1",
"jsdom": "3.1.2",
"superagent": "0.12.4"
},
"devDependencies": {
......
......@@ -8,12 +8,23 @@
#
################################################################################
require 'should'
set = (require '../lib/set-express').render
# Fix to the Mocha colours being unreadable on my Terminal theme.
colors = require('mocha/lib/reporters/base').colors
colors['pass'] = colors['error stack'] = colors['light'] = colors['diff gutter'] = '92'
describe 'Set', ->
#
# Doctype
#
it 'should render the doctype', ->
set('<!DOCTYPE html><html><p>I am an HTML 5 document</p></html>', {}).should.equal('<!DOCTYPE html><html><head></head><body><p>I am an HTML 5 document</p></body></html>')
#
# Text
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment