diff --git a/README.md b/README.md index 54e9864..a9622a7 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Simplify developers' lives by abstracting template rendering for multiple templa | ECR | .ecr | none (part of the stdlib) | | | Mustache | .mustache | [crustache](https://github.com/MakeNowJust/crustache) | [@MakeNowJust](https://github.com/MakeNowJust) | | 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) | See also: [Registering your own template engine](#registering-your-own-template-engine). @@ -25,7 +26,7 @@ Add this to your application's `shard.yml`: dependencies: kilt: github: jeromegn/kilt - + # Any other template languages Crystal shard ``` @@ -100,3 +101,4 @@ Please contribute your own "adapter" if you create a template language for Cryst - [jeromegn](https://github.com/jeromegn) Jerome Gravel-Niquet - creator, maintainer - [waterlink](https://github.com/waterlink) Oleksii Fedorov - [MakeNowJust](https://github.com/MakeNowJust) TSUYUSATO Kitsune +- [f](https://github.com/f) Fatih Kadir Akın diff --git a/shard.yml b/shard.yml index 91e707f..e906cff 100644 --- a/shard.yml +++ b/shard.yml @@ -11,3 +11,5 @@ development_dependencies: github: jeromegn/slang crustache: github: MakeNowJust/crustache + temel: + github: f/temel diff --git a/spec/fixtures/test.temel b/spec/fixtures/test.temel new file mode 100644 index 0000000..b214e1f --- /dev/null +++ b/spec/fixtures/test.temel @@ -0,0 +1 @@ +span Process.pid diff --git a/spec/kilt/temel_spec.cr b/spec/kilt/temel_spec.cr new file mode 100644 index 0000000..84e92df --- /dev/null +++ b/spec/kilt/temel_spec.cr @@ -0,0 +1,18 @@ +require "../spec_helper" +require "../../src/kilt/temel" + +class TemelView + Kilt.file "spec/fixtures/test.temel" +end + +describe "kilt/temel" do + + it "renders temel" do + Kilt.render("spec/fixtures/test.temel").should eq("#{Process.pid}") + end + + it "works with classes" do + TemelView.new.to_s.should eq("#{Process.pid}") + end + +end diff --git a/src/kilt/helpers/temel_embedder.cr b/src/kilt/helpers/temel_embedder.cr new file mode 100644 index 0000000..38967c2 --- /dev/null +++ b/src/kilt/helpers/temel_embedder.cr @@ -0,0 +1,3 @@ +require "temel" + +puts File.read(ARGV[0]).to_s STDOUT diff --git a/src/kilt/temel.cr b/src/kilt/temel.cr new file mode 100644 index 0000000..0477be6 --- /dev/null +++ b/src/kilt/temel.cr @@ -0,0 +1,9 @@ +require "../kilt" +require "temel" + +macro embed_temel(filename, __kilt_io__) + __kilt_io__ << {{ run("./helpers/temel_embedder.cr", filename) }} + __kilt_io__ +end + +Kilt.register_engine "temel", embed_temel