Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/domgetter/crikey
Data structure view templates for Crystal
https://github.com/domgetter/crikey
Last synced: about 1 month ago
JSON representation
Data structure view templates for Crystal
- Host: GitHub
- URL: https://github.com/domgetter/crikey
- Owner: domgetter
- License: mit
- Created: 2017-04-01T17:36:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-26T20:37:15.000Z (about 7 years ago)
- Last Synced: 2024-08-03T17:14:49.242Z (4 months ago)
- Language: Crystal
- Size: 5.86 KB
- Stars: 15
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - crikey - Templating engine inspired by [Hiccup](https://github.com/weavejester/hiccup) (Template Engine)
README
# crikey
Crikey is a templating engine inspired by [Hiccup](https://github.com/weavejester/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`:
```yaml
dependencies:
crikey:
github: domgetter/crikey
```## Usage
### Standalone
```crystal
require "crikey"Crikey.to_html([:div, [:span, "Hello"]])
#=> "Hello"
```### with Kilt
Example with Kemal:
```crystal
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)
```crystal
[:div, {id: "users"},
users.map do |user|
[:div, {class: "user"},
[:span, user[:id]],
[:span, {style: "color: red"},
user[:name]]]
end
]
```
And you will get
```html
7
Samantha
24
Mikey
```
It's just data!## Contributing
1. Fork it ( https://github.com/domgetter/crikey/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request## Contributors
- [domgetter](https://github.com/domgetter) Dominic Muller - creator, maintainer