Compare commits

...

12 commits

Author SHA1 Message Date
Jerome Gravel-Niquet
b7289f80ad
bump version to 0.6.1 2021-03-24 07:53:32 -04:00
Jerome Gravel-Niquet
7ffc3e82f2
Merge pull request #25 from kachick/follow-crystal-1.0.0
Follow crystal 1.0.0 in shard.yml
2021-03-24 07:52:35 -04:00
Kenichi Kamiya
ebeb955e53 Follow crystal 1.0.0 in shard.yml 2021-03-24 00:54:28 +09:00
Hugo Parente Lima
bd8e6fd144 Remove broken links from README.
https://shards.rocks site doesn't exists anymore.
2020-04-13 06:54:16 -04:00
Shootingfly
8282f54139 bump 0.6.0 2019-11-01 16:17:24 +00:00
Shootingfly
fe1a382088 Add water 2019-11-01 16:17:24 +00:00
Rocky
d2c3c6b5ba Mention jbuilder support and bump version to 0.5.0 (#21)
* Mention jbuilder support in README.md

* bump 0.5.0
2019-10-16 16:05:06 +00:00
Rocky
7603087d3d Add jbuilder (#20) 2019-10-15 12:23:55 -04:00
Davor Ocelic
43a5c472a6 Update Liquid support's maintainer name (#19) 2019-04-23 09:14:54 -04:00
Zack Kollar
0339265b3d Added latest version to crystal in travis.yml (#17) 2018-09-26 10:22:18 -04:00
Davor Ocelic
ddba8f9050 Mention Liquid.cr support in README.md (#16) 2018-02-11 10:12:32 -05:00
Davor Ocelic
bfd630f35c Add liquid.cr support (#15)
* Add liquid.cr support

* Minor

* Add specs for passing custom context to Liquid

E.g.:

context = Liquid::Context.new
context.set "key", "value"
render( "/path/to/template.liquid", context)
2018-02-10 14:21:11 -05:00
13 changed files with 97 additions and 3 deletions

View file

@ -1 +1,3 @@
language: crystal
crystal:
- latest

View file

@ -1,4 +1,4 @@
# Kilt [![Build Status](https://travis-ci.org/jeromegn/kilt.svg?branch=master)](https://travis-ci.org/jeromegn/kilt) [![Dependency Status](https://shards.rocks/badge/github/jeromegn/kilt/status.svg)](https://shards.rocks/github/jeromegn/kilt) [![devDependency Status](https://shards.rocks/badge/github/jeromegn/kilt/dev_status.svg)](https://shards.rocks/github/jeromegn/kilt)
# Kilt [![Build Status](https://travis-ci.org/jeromegn/kilt.svg?branch=master)](https://travis-ci.org/jeromegn/kilt)
Generic templating interface for Crystal.
@ -15,6 +15,9 @@ Simplify developers' lives by abstracting template rendering for multiple templa
| Slang | .slang | [slang](https://github.com/jeromegn/slang) | [@jeromegn](https://github.com/jeromegn) |
| Temel | .temel | [temel](https://github.com/f/temel) | [@f](https://github.com/f) |
| Crikey | .crikey | [crikey](https://github.com/domgetter/crikey) | [@domgetter](https://github.com/domgetter) |
| Liquid | .liquid | [liquid](https://github.com/TechMagister/liquid.cr) | [@docelic](https://github.com/docelic) |
| Jbuilder | .jbuilder | [jbuilder](https://github.com/shootingfly/jbuilder) | [@shootingfly](https://github.com/shootingfly) |
| Water | .water | [water](https://github.com/shootingfly/water) | [@shootingfly](https://github.com/shootingfly) |
See also:
[Registering your own template engine](#registering-your-own-template-engine).

View file

@ -1,5 +1,6 @@
name: kilt
version: 0.4.0
version: 0.6.1
crystal: '< 2.0.0'
authors:
- Jerome Gravel-Niquet <jeromegn@gmail.com>
@ -13,3 +14,9 @@ development_dependencies:
github: MakeNowJust/crustache
temel:
github: f/temel
liquid:
github: TechMagister/liquid.cr
jbuilder:
github: shootingfly/jbuilder
water:
github: shootingfly/water

1
spec/fixtures/test.jbuilder vendored Normal file
View file

@ -0,0 +1 @@
json.span Process.pid

1
spec/fixtures/test.liquid vendored Normal file
View file

@ -0,0 +1 @@
<span>{{ process.pid }}</span>

1
spec/fixtures/test.water vendored Normal file
View file

@ -0,0 +1 @@
span Process.pid

View file

@ -0,0 +1,18 @@
require "../spec_helper"
require "../../src/jbuilder"
class JbuilderView
Kilt.file "spec/fixtures/test.jbuilder"
end
describe "kilt/jbuilder" do
it "renders jbuilder" do
Kilt.render("spec/fixtures/test.jbuilder").should eq("{\"span\":#{Process.pid}}")
end
it "works with class" do
JbuilderView.new.to_s.should eq("{\"span\":#{Process.pid}}")
end
end

31
spec/kilt/liquid_spec.cr Normal file
View file

@ -0,0 +1,31 @@
require "../spec_helper"
require "../../src/liquid"
class LiquidView
@process = { "pid" => Process.pid }
Kilt.file "spec/fixtures/test.liquid"
end
class LiquidViewWithCustomContext
# Use of instance variable is not required in user code. It is used here to
# avoid name clash with 'context' variable existing within spec.
def initialize
@context = Liquid::Context.new
@context.set "process", { "pid" => Process.pid }
end
Kilt.file "spec/fixtures/test.liquid", "__kilt_io__", "@context"
end
it "renders liquid" do
ctx = Liquid::Context.new
ctx.set "process", { "pid" => Process.pid }
Kilt.render("spec/fixtures/test.liquid", ctx).should eq("<span>#{Process.pid}</span>\n")
end
it "works with classes" do
LiquidView.new.to_s.should eq("<span>#{Process.pid}</span>\n")
end
it "works with classes and custom context" do
LiquidViewWithCustomContext.new.to_s.should eq("<span>#{Process.pid}</span>\n")
end

18
spec/kilt/water_spec.cr Normal file
View file

@ -0,0 +1,18 @@
require "../spec_helper"
require "../../src/water"
class WaterView
Kilt.file "spec/fixtures/test.water"
end
describe "kilt/water" do
it "renders water" do
Kilt.render("spec/fixtures/test.water").should eq("<span>#{Process.pid}</span>")
end
it "works with class" do
WaterView.new.to_s.should eq("<span>#{Process.pid}</span>")
end
end

4
src/jbuilder.cr Normal file
View file

@ -0,0 +1,4 @@
require "./kilt"
require "jbuilder"
Kilt.register_engine "jbuilder", Jbuilder.embed

View file

@ -1,3 +1,3 @@
module Kilt
VERSION = "0.4.0"
VERSION = "0.6.1"
end

4
src/liquid.cr Normal file
View file

@ -0,0 +1,4 @@
require "./kilt"
require "liquid"
Kilt.register_engine "liquid", Liquid.embed

4
src/water.cr Normal file
View file

@ -0,0 +1,4 @@
require "./kilt"
require "water"
Kilt.register_engine "water", Water.embed