-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
I'm using CoffeeCup to create SVG content. This works great except for one issue. SVG has a <text> element. But in CoffeeCup, the obvious way of creating such elements doesn't work. I want to generate <text x="42" y="13">Hello</text>.
text {x: 42, y:13}, 'Hello'
This only produces [Object], as it invokes the text helper function instead of a tag function. A workaround I found is to define my own helper function that can create arbitrary elements:
helpers = element: (tagname, args...) -> __cc.tag(tagname, args)
coffeecup.render myTemplate, myData, hardcode: helpers
I use it like this in the template to produce the desired result:
element 'text', {x: 42, y:13}, 'Hello'
Maybe a similar function could be added to the CoffeeCup DSL, to deal with this situation, as well as any other potential future situation where an element name may clash with a helper or reserved word?
Metadata
Metadata
Assignees
Labels
No labels