Skip to content

Instantly share code, notes, and snippets.

@flyingmachine
Created January 19, 2014 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyingmachine/8507816 to your computer and use it in GitHub Desktop.
Save flyingmachine/8507816 to your computer and use it in GitHub Desktop.
(div :class "filters"
(loop-tpl :bindings [name ["bob" "joe"]]
(div
(h3 (text "~{name}"))
(ul
(loop-tpl :bindings [attr ["a" "b"]]
(li (text "~{attr}")))))))
@micha
Copy link

micha commented Jan 19, 2014

(defc names ["bob" "joe"])
(defc attrs ["a" "b"])

...

(div :class "filters"
  (loop-tpl 
    :bindings [name names]
    (div
      (h3 (text "~{name}"))
      (ul
        (loop-tpl 
          :bindings [attr attrs]
          (li (text "~{attr}")))))))

@micha
Copy link

micha commented Jan 19, 2014

(defc people 
  [{:name "bob" :attrs ["a" "b"]}
   {:name "joe" :attrs ["c" "d"]}])

...

(div :class "filters"
  (loop-tpl 
    :bindings [{:keys [name attrs]} people]
    (div
      (h3 (text "~{name}"))
      (ul
        (loop-tpl 
          :bindings [attr attrs]
          (li (text "~{attr}")))))))

@micha
Copy link

micha commented Jan 19, 2014

<script type="text/hoplon">
  (defc people 
    [{:name "bob" :attrs ["a" "b"]}
     {:name "joe" :attrs ["c" "d"]}])
</script>

...

<div class="filters">
  <loop-tpl 
    bindings="{{ [{:keys [name attrs]} people] }}">
    <div>
      <h3><text>~{name}</text></h3>
      <ul>
        <loop-tpl 
          bindings="{{ [attr attrs] }}">
          <li><text>~{attr}</text></li>
        </loop-tpl>
      </ul>
    </div>
  </loop-tpl>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment