mirror of
https://gitea.invidious.io/iv-org/shard-kilt.git
synced 2024-08-15 00:43:15 +00:00
Added Mustache adapter
This commit is contained in:
parent
a222267254
commit
ae9e097221
5 changed files with 41 additions and 5 deletions
|
@ -8,9 +8,10 @@ Simplify developers' lives by abstracting template rendering for multiple templa
|
||||||
|
|
||||||
## Supported out of the box
|
## Supported out of the box
|
||||||
|
|
||||||
| Language | File extensions | Required libraries |
|
| Language | File extensions | Required libraries | Maintainer |
|
||||||
| -------- | --------------- | ------------------ |
|
| -------- | --------------- | ------------------ | ---------- |
|
||||||
| ECR | .ecr | none (part of the stdlib) |
|
| ECR | .ecr | none (part of the stdlib) | |
|
||||||
|
| Mustache | .mustache | [crustache](https://github.com/MakeNowJust/crustache) | [@MakeNowJust](https://github.com/MakeNowJust) |
|
||||||
|
|
||||||
See also:
|
See also:
|
||||||
[Registering your own template engine](#registering-your-own-template-engine).
|
[Registering your own template engine](#registering-your-own-template-engine).
|
||||||
|
@ -92,4 +93,4 @@ Please contribute your own "adapter" if you create a template language for Cryst
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
- [jeromegn](https://github.com/jeromegn) Jerome Gravel-Niquet - creator, maintainer
|
- [jeromegn](https://github.com/jeromegn) Jerome Gravel-Niquet - creator, maintainer
|
||||||
- [waterlink](https://github.com/waterlink) Oleksii Fedorov
|
- [waterlink](https://github.com/waterlink) Oleksii Fedorov
|
||||||
|
|
|
@ -4,4 +4,8 @@ version: 0.1.0
|
||||||
authors:
|
authors:
|
||||||
- Jerome Gravel-Niquet <jeromegn@gmail.com>
|
- Jerome Gravel-Niquet <jeromegn@gmail.com>
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
|
development_dependencies:
|
||||||
|
crustache:
|
||||||
|
github: MakeNowJust/crustache
|
||||||
|
|
1
spec/fixtures/test.mustache
vendored
Normal file
1
spec/fixtures/test.mustache
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<span>{{pid}}</span>
|
26
spec/mustache_spec.cr
Normal file
26
spec/mustache_spec.cr
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
require "./spec_helper"
|
||||||
|
require "../src/mustache"
|
||||||
|
|
||||||
|
class MustacheView
|
||||||
|
def has_key?(name)
|
||||||
|
name == "pid"
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](name)
|
||||||
|
name == "pid" ? Process.pid : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
Kilt.file "spec/fixtures/test.mustache", "__kilt_io__", self
|
||||||
|
end
|
||||||
|
|
||||||
|
describe Kilt do
|
||||||
|
|
||||||
|
it "renders ecr" do
|
||||||
|
Kilt.render("spec/fixtures/test.mustache", { "pid" => Process.pid }).should eq("<span>#{Process.pid}</span>")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "works with classes" do
|
||||||
|
MustacheView.new.to_s.should eq("<span>#{Process.pid}</span>")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
4
src/mustache.cr
Normal file
4
src/mustache.cr
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
require "./kilt"
|
||||||
|
require "crustache"
|
||||||
|
|
||||||
|
Kilt.register_engine "mustache", embed_mustache
|
Loading…
Reference in a new issue