Skip to content

SVG text elements do not work due to clash with text helper function #72

@cygri

Description

@cygri

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions