crikey
crikey
Crikey is a templating engine inspired by Hiccup. It is focused on mapping snippets of view code and logic to data structures available in the language.
Installation
Add this to your application's shard.yml
:
dependencies:
crikey:
github: domgetter/crikey
Usage
Standalone
require "crikey"
Crikey.to_html([:div, [:span, "Hello"]])
#=> "<div><span>Hello</span></div>"
with Kilt
Example with Kemal:
require "kilt/crikey"
get "/users" do
users = [{name: "Samantha", id: 7}, {name: "Mikey", id: 24}] # this would be the result of a db call
render "src/views/users.crikey"
end
(in users.crikey)
[:div, {id: "users"},
users.map do |user|
[:div, {class: "user"},
[:span, user[:id]],
[:span, {style: "color: red"},
user[:name]]]
end
]
And you will get
<div id="users">
<div class="user">
<span>7</span>
<span style="color: red">Samantha</span>
</div>
<div class="user">
<span>24</span>
<span style="color: red">Mikey</span>
</div>
</div>
It's just data!
Contributing
- Fork it ( https://github.com/domgetter/crikey/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- domgetter Dominic Muller - creator, maintainer
Repository
crikey
Owner
Statistic
- 15
- 1
- 2
- 1
- 0
- about 7 years ago
- April 1, 2017
License
MIT License
Links
Synced at
Sat, 21 Dec 2024 15:20:19 GMT
Languages