Permalink
Browse files

call toString on passed in template

  • Loading branch information...
1 parent eedd51e commit 019aa4db5811db8059825898ac591c9e2c98fa32 @amccollum committed Apr 26, 2012
Showing with 14 additions and 12 deletions.
  1. +0 −2 Cakefile
  2. +1 −0 lib/ender.js
  3. +6 −4 lib/wings.js
  4. +1 −1 package.json
  5. +3 −3 src/test/wings-test.coffee
  6. +3 −2 src/wings/wings.coffee
View
@@ -1,8 +1,6 @@
fs = require('fs')
{spawn, exec} = require('child_process')
-package = JSON.parse(fs.readFileSync('package.json', 'utf8'))
-
execCmds = (cmds) ->
exec cmds.join(' && '), (err, stdout, stderr) ->
output = (stdout + stderr).trim()
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "wings",
- "version": "0.5.6",
+ "version": "0.5.7",
"description": "Templating library that works on the server and client closely modeled on Mustache",
"keywords": ["ender", "template", "mustache", "html"],
"author": "Andrew McCollum <amccollum@gmail.com>",
@@ -23,7 +23,7 @@ vows.add 'templates'
topic: [
t('I think, {{therefore I am.}}'),
t('I }}{{think, {{{{therefore I am.}}}}'),
- t('nested {{ {:truthy} {{ braces }} {{ {/truthy} }}', {truthy: true}),
+ t('nested {{ {:truthy}{{ braces }} {{{/truthy} }}', {truthy: true}),
]
'should have double braces replaced with single braces': (topics) ->
@@ -175,13 +175,13 @@ vows.add 'templates'
tmpls: [
{ name: 'tmpl1', text: 'The {adj1}, {adj2} fox {verb1} over the {adj3} dogs.' },
{ name: 'tmpl2', text: '{:untrue}foo{/untrue}bar' },
- { name: 'tmpl3', text: 'nested {{ {:truthy} {{ braces }} {{ {/truthy} }}' },
+ { name: 'tmpl3', text: 'nested {{ {:truthy}{{ braces }} {{{/truthy} }}' },
]})
'should insert the subtemplates unmodified': (topic) ->
equal topic, '''tmpl1: 'The {adj1}, {adj2} fox {verb1} over the {adj3} dogs.',
tmpl2: '{:untrue}foo{/untrue}bar',
- tmpl3: 'nested {{ {:truthy} {{ braces }} {{ {/truthy} }}',
+ tmpl3: 'nested {{ {:truthy}{{ braces }} {{{/truthy} }}',
'''.replace(/\n/g, '')
'templates with undefined sections':
View
@@ -3,6 +3,7 @@
wings.renderTemplate = (template, data, links) ->
# Replace escaped braces with an obscure unicode curly brace
+ template = template.toString()
template = replaceBraces(template)
template = renderRawTemplate(template, data, links)
template = restoreBraces(template)
@@ -17,13 +18,13 @@
return s.toString().replace /&(?!\w+;)|["<>]/g, (s) ->
switch s
when '&' then return '&amp;'
- when '"' then return '\"'
+ when '"' then return '&#34;'
when '<' then return '&lt;'
when '>' then return '&gt;'
else return s
parsePattern = ///
- \s* \{([:!]) \s* ([^}]*?) \s* \} ([\S\s]+?) \s* \{/ \s* \2 \s*\} | # sections
+ \{([:!]) \s* ([^}]*?) \s* \} ([\S\s]+?) \s* \{/ \s* \2 \} | # sections
\{(\#) [\S\s]+? \#\} | # comments
\{([@&]?) \s* ([^}]*?) \s* \} # tags
///mg

0 comments on commit 019aa4d

Please sign in to comment.