diff --git a/README.md b/README.md index 7e0450f..77f11ec 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,14 @@ dependencies: # Any other template languages Crystal shard ``` -Kilt essentially adds two macros `Kilt.embed` and `Kilt.file`, the code is really simple. - ## Usage -Add template language dependencies, as listed in the support table above. +- Kilt essentially adds two macros `Kilt.embed` and `Kilt.file`, the code is really simple. +- Add template language dependencies, as listed in the support table above. + +Both macros take a `filename` and a `io_name` (the latter defaults to `"__kilt_io__"`) + +### Example ```crystal require "kilt" @@ -45,8 +48,8 @@ puts YourView.new.to_s # => # Embedded -str = String.build do |str| - Kilt.embed "path/to/template.slang", "str" +str = String.build do |__kilt_io__| + Kilt.embed "path/to/template.slang" end puts str # => diff --git a/src/kilt.cr b/src/kilt.cr index b9ff7d2..b9c2549 100644 --- a/src/kilt.cr +++ b/src/kilt.cr @@ -2,8 +2,8 @@ require "ecr/macros" require "./kilt/*" module Kilt - - macro embed(filename, io_name = "__io__") + + macro embed(filename, io_name = "__kilt_io__") {% if filename.ends_with?(".ecr") %} embed_ecr({{filename}}, {{io_name}}) {% elsif filename.ends_with?(".slang") %} @@ -13,9 +13,9 @@ module Kilt {% end %} end - macro file(filename) - def to_s(__io__) - Kilt.embed({{filename}}, "__io__") + macro file(filename, io_name = "__kilt_io__") + def to_s({{io_name.id}}) + Kilt.embed({{filename}}, {{io_name}}) end end diff --git a/src/kilt/version.cr b/src/kilt/version.cr index 11e892d..6857872 100644 --- a/src/kilt/version.cr +++ b/src/kilt/version.cr @@ -1,3 +1,3 @@ module Kilt - VERSION = "0.1.0" + VERSION = "0.1.1" end