Mustache and Haml

后端 未结 1 1149
小鲜肉
小鲜肉 2021-01-01 02:31

I have got this haml/mustache template:

{{#data}}
  ok
  {{#items}}
    {{#item}}
      %b ID: {{id}}
    {{/item}}
  {{/items}}
{{/data}}

相关标签:
1条回答
  • 2021-01-01 03:16

    I'm not sure about rendering with Sinatra, but with this command:

    cat example.yml foo.haml.mustache | mustache | haml -e
    

    this data file example.yml

    ---
    data:
      - items:
        - item:
          - id: 1
          - id: 2
          - id: 3
    ---    
    

    and template (foo.haml.mustache ):

    {{#data}}
    #ok
    {{#items}}
    {{#item}}
      %b ID: {{id}}
    {{/item}}
    {{/items}}
    {{/data}}
    

    I get following result:

    <div id='ok'>
      <b>ID: 1</b>
      <b>ID: 2</b>
      <b>ID: 3</b>
    </div>
    

    Pls pay attention to indentation level in *.mustache file. Hope this help you.

    0 讨论(0)
提交回复
热议问题