javascripttemplatesnode.jscoffeescriptcoffeekup

How can I use literal HTML in a CoffeeKup template?


I'm becoming a huge fan of CoffeeKup, but I'm wondering how I can use literal HTML in such a template? For example when I just want to copy-paste some existing, non-CoffeeKup markup.


Solution

  • You can add arbitrary text with the text function:

    text '<p>foo</p>'
    

    For multiline strings, CoffeeScript's heredocs are a pleasure:

    text '''
      <table>
        <tr>
          <td>Foo</td>
        </tr>
      </table>
    '''
    

    Just make sure you have autoescape set to false (the default value).