开发者

Handlebars inside of Markdown, inside of HAML

开发者 https://www.devze.com 2023-04-10 02:15 出处:网络
I know that this is a very non-standard use case, but I\'m chaining HAML, Markdown, and Handlebars (in SproutCore 2.0), and I\'m 1 step away from \'beautiful\' code.Intermingling HAML, Markdown, and J

I know that this is a very non-standard use case, but I'm chaining HAML, Markdown, and Handlebars (in SproutCore 2.0), and I'm 1 step away from 'beautiful' code. Intermingling HAML, Markdown, and Javascript is less ideal than it could be. If I wanted to add a post-filter to the entire output of HAML, replacing {{text}} with <script>{{text}}</开发者_运维问答script>, what would be the best way to do it?

I could just hack on a post-build step after haml, but I'd like to turn it into something that I can give back to the SproutCore community.

I want to replace

%body
  javascript:
    {{handlebars}}

With

%body
  {{handlebars}}

Which would give me

<body>
  <script>{{handlebars}}</script>
</body>

However, I also want this to work when embedded within markdown. For example,

%body
  markdown:
    # Hello, {{handlebars}}

Currently, the only way to get this is

%body
  markdown:
    # Hello, <script>{{handlebars}}</script>

Which would product

<body>
  <h1>Hello, <script>{{handlebars}}</script></h1>
</body>


Revisiting the same issue much, much later, it appears that there's not a good solution for this with HAML. However, Jade does just about everything that I want.

http://jade-lang.com/

Input

html
  script(type='text/x-handlebars')
    :markdown
      *Hello, {{handlebars}}!*

Output

<html>
  <script type="text/x-handlebars"><p><em>Hello, {{handlebars}}!</em></p>
  </script>
</html>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号