Navigation Menu

Skip to content

Commit

Permalink
doctypes are default off
Browse files Browse the repository at this point in the history
  • Loading branch information
dodo committed Nov 15, 2011
1 parent 699601b commit 770676d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/template.coffee
Expand Up @@ -116,6 +116,7 @@ class Template extends EventEmitter
constructor: (opts = {}, template) ->
[template, opts] = [opts, {}] if typeof opts is 'function'
opts.encoding ?= 'utf-8'
opts.doctype ?= off
schema_input = opts.schema
s = aliases[schema_input] or schema_input or 'xml'
opts.self_closing = self_closing[s]?(opts)
Expand Down Expand Up @@ -145,7 +146,10 @@ class Template extends EventEmitter
@emit event, args...

process.nextTick =>
if schema_input? and (dt = doctype[s]?(opts))
if opts.doctype is on
opts.doctype = 'html'
d = aliases[opts.doctype] or opts.doctype
if opts.doctype and (dt = doctype[d]?(opts))
dt += "\n" if opts.pretty
@xml.emit 'data', dt
if typeof template is 'function'
Expand Down
5 changes: 2 additions & 3 deletions src/test/template.coffee
Expand Up @@ -13,7 +13,7 @@ module.exports =

html5: (æ) ->
content = ["a", "b", "c"]
xml = new Template schema:5, ->
xml = new Template schema:5, doctype:on, ->
@$html ->
@body ->
file = path.join(__dirname,"..","..","..","filename")
Expand Down Expand Up @@ -50,7 +50,7 @@ module.exports =
]

pretty: (æ) ->
xml = new Template schema:5, pretty:" ", ->
xml = new Template schema:5, pretty:" ", doctype:on, ->
@$html ->
@$head ->
@$title "holla"
Expand Down Expand Up @@ -98,7 +98,6 @@ module.exports =
xml.on 'end', æ.done
xml.on 'data', (tag) -> æ.equal results.shift(), tag
results = [
'<!DOCTYPE html>'
'<html>'
'<head>'
'<title>'
Expand Down

0 comments on commit 770676d

Please sign in to comment.