Markdown 内的把手、HAML 内的把手
我知道这是一个非常不标准的用例,但我链接了 HAML、Markdown 和 Handlebars(在 SproutCore 2.0 中),距离“美丽”代码只有一步之遥。混合 HAML、Markdown 和 Javascript 并不理想。如果我想向 HAML 的整个输出添加后置过滤器,请将 {{text}}
替换为 ,最好的方法是什么?
我可以在 haml
之后修改构建后步骤,但我想将其变成可以回馈 SproutCore 社区的东西。
我想替换
%body
javascript:
{{handlebars}}
为
%body
{{handlebars}}
Which 会给我
<body>
<script>{{handlebars}}</script>
</body>
但是,我也希望它在嵌入到 markdown 中时也能工作。例如,
%body
markdown:
# Hello, {{handlebars}}
目前,获得此结果的唯一方法是
%body
markdown:
# Hello, <script>{{handlebars}}</script>
Which will Product
<body>
<h1>Hello, <script>{{handlebars}}</script></h1>
</body>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很久以后重新审视同一问题,HAML 似乎没有一个好的解决方案。然而,杰德几乎做了我想做的一切。
http://jade-lang.com/
输入
输出
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
Output