How to include a comment in an inline yesod javascript template

80 views Asked by At

In the code

toWidget [julius|
     $(function() {
        foo();
        bar();
     )
|]

I want to comment out the call to bar. But

toWidget [julius|
     $(function() {
        foo();
        /* bar(); */
     )
|]

trips up the C preprocessor, while Haskell style comments, i.e.

toWidget [julius|
     $(function() {
        foo();
        {- bar(); -}
     )
|]

go through to the browser.

This is a small example; my real case spans several lines, so a multi-line-commenting style would be required.

How would I comment out something in a shakespearian template, in particular a julius template?

1

There are 1 answers

0
Michael Snoyman On BEST ANSWER

If you're asking specifically about Julius templates, the answer is that there isn't any built-in commenting syntax, and therefore the only option is JavaScript style comments. However, as you've mentioned, this can conflict with the CPP language extension.

One option to work around this is to put the template in an external file instead of using quasiquoting. Another possibility I've never actually tried is to use CPP commenting, e.g. #if 0.