coolony / kiwi

Simple yet powerful asynchronous JavaScript template engine based on jQuery Template syntax, usable server-side or client-side.
MIT License
41 stars 6 forks source link

SyntaxError: Unexpected token } #17

Open panosru opened 12 years ago

panosru commented 12 years ago

Hi, I use Kiwi as my primary server side templating engine and I also use Handlebars with EmberJS for client-side so I tried today to do something like this: ${'{{action anActionName}}'|raw} but I got SyntaxError: Unexpected token } this works: {{raw}}{{action anActionName}}{{/raw}} but I think that the first should also work since I pass the raw filter.

Thanks :)

pierreis commented 12 years ago

I think you made a mistake here. This is probably a naming issue however. The raw tag has nothing in common with the raw filter. The first just avoids auto HTML escaping, whereas the latter instructs the parser to simply ignore the markup contained in it.

The SyntaxError is caused by the parser. It tends to bite when } is contained inside of a tag, even in strings. This will be fixed soon.

panosru commented 12 years ago

aha yes indeed I though that raw filter is a shortcut of raw tag, for instance when you have something short like the example above you could use ${'{{action anActionName}}'|raw} but when you have something more complex that would take more lines you would use:

<script type="text/x-handlebars" data-template-name="contributors">
  {{#each person in controller}}
    {{person.login}}
  {{/each}}
</script>

Regarding the html escape I would expect a safe filter instead that would mark the output as safe in order for the automatic escape to not convert html tags to entities.