javascript - Any client side haml parser? - Stack Overflow

I'm looking to render my haml code in client side using JavaScript. There are nice haml parsers in

I'm looking to render my haml code in client side using JavaScript. There are nice haml parsers in server side like Jade or haml.js but I don't know any haml parser/decoder in client side.

Update: Jade that is pretty much haml now supports client side.

I'm looking to render my haml code in client side using JavaScript. There are nice haml parsers in server side like Jade or haml.js but I don't know any haml parser/decoder in client side.

Update: Jade that is pretty much haml now supports client side.

Share Improve this question edited Jun 21, 2012 at 21:39 Mohsen asked Dec 12, 2011 at 23:03 MohsenMohsen 65.9k36 gold badges164 silver badges187 bronze badges 1
  • 1 found jquery-haml - not really haml but pretty close – froderik Commented Dec 13, 2011 at 13:58
Add a ment  | 

1 Answer 1

Reset to default 8

After some googling I found the "client-side-haml-js" github project. Looks like it should meet your needs:

The clientside-haml-js is a piler written in CoffeeScript that piles text templates in HAML format into Javascript functions that generate HTML. It has been inspired by the server side haml Javascript project, and has been written to be feature patible with Ruby server side HAML, supports all major browsers (IE 7+, Firefox 3.6+, Chrome 10+, Safari), have minimal runtime dependencies (only underscore.js, underscore.string and CoffeeScript if using CoffeeScript in your templates).

NOTE: The haml piler requires a browser with a JSON parser. For browsers like IE7, you need to also include a JSON implementation. See http://www.json/ for more details. A JSON implementation is available at https://github./douglascrockford/JSON-js.

Example from their github page:

var fn = haml.pileStringToJs("%h1\n  %div\n    %p\n    %span");
var html = fn();

Looks like it also supports a text/haml-template method similar to jquery-templates:

<script type="text/haml-template" id="simple">
%h1
  %div
    %p
    %span
</script>

<script type="text/javascript">
    var fn = haml.pileHaml('simple');
    var html = fn();
</script>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744804286a4594680.html

相关推荐

  • javascript - Any client side haml parser? - Stack Overflow

    I'm looking to render my haml code in client side using JavaScript. There are nice haml parsers in

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信