Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diet template does not support :javascript filter, yet? #9

Closed
zhaopuming opened this issue Apr 27, 2012 · 4 comments
Closed

Diet template does not support :javascript filter, yet? #9

zhaopuming opened this issue Apr 27, 2012 · 4 comments
Assignees

Comments

@zhaopuming
Copy link

I can't find a way to write <script> javascript code in diet template, they all seem to be escaped somehow.

Scalate (Jade with Scala) supports <script> javascript code by a :javascript filter, as shown in this page

http://scalate.fusesource.org/documentation/jade.html

:javascript
  if (foo) {
     bar()
  }

Will that be supported soon? or else how can I write javascript code in the templates?

@ricochet1k
Copy link
Contributor

Jade shows just using a script tag directly:

html
  head
    title Example
    script
      if (foo) {
        bar();
      } else {
        baz();
      }

@s-ludwig
Copy link
Member

I have not needed it up to now, but I will add the nested "script" syntax for this and the the :javascript one afterwards.

For now, the script needs to be in a separate file served with e.g. serveStaticFiles("./public/") and script(type="text/javascript", src="script.js") is needed in the template.

@ghost ghost assigned s-ludwig Apr 28, 2012
@zhaopuming
Copy link
Author

OK, thanks :) I'll wait for this feature. Sometimes I may need to access D code page attributes in the javascript code, and inline script would make this possible. For filters, :markdown, :coffeescript (as implemented in Scalate's jade) and even customized ones are useful too. Maybe you can create a extension point here for people to plug in their own filter implementations :)

s-ludwig added a commit that referenced this issue Apr 28, 2012
…able to specify inline JavaScript and CSS.

Also added the shortcuts ':css' and ':javascript' for style(type="text/css") et al.
Fixes issue #9.
@s-ludwig
Copy link
Member

script, style, :css and :javascript work now :). :css and :javascript are not real filters yet, but just simple shortcuts. I put real filter support as a TODO item (the markdown parser would be very useful to have as a filter).
Customized filters unfortunately may be more difficult because they need to run at compile time - so they would have to be somehow passed to the parser as a D template argument. But this would make the interface kind of ugly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants