mirror of
https://gitea.invidious.io/iv-org/shard-kilt.git
synced 2024-08-15 00:43:15 +00:00
Simplify logic further via registering extensions without dot
This commit is contained in:
parent
a43ad3c09c
commit
69b31b6e5d
3 changed files with 5 additions and 6 deletions
|
@ -70,7 +70,7 @@ module MyEngine
|
|||
end
|
||||
end
|
||||
|
||||
Kilt.register_template(".myeng", ::MyEngine.embed)
|
||||
Kilt.register_template("myeng", ::MyEngine.embed)
|
||||
```
|
||||
|
||||
This can be part of your own `my-engine` library: in this case it should depend
|
||||
|
|
|
@ -2,7 +2,7 @@ require "spec"
|
|||
require "../src/kilt"
|
||||
|
||||
require "slang"
|
||||
Kilt.register_template(".slang", embed_slang)
|
||||
Kilt.register_template("slang", embed_slang)
|
||||
|
||||
macro render_file(filename)
|
||||
String.build do |__io__|
|
||||
|
|
|
@ -11,10 +11,9 @@ module Kilt
|
|||
|
||||
macro embed(filename, io_name = "__kilt_io__")
|
||||
{% ext = filename.split(".").last %}
|
||||
{% ext_with_dot = ".#{ext.id}" %}
|
||||
|
||||
{% if ::Kilt::TEMPLATES[ext_with_dot] %}
|
||||
{{::Kilt::TEMPLATES[ext_with_dot]}}({{filename}}, {{io_name}})
|
||||
{% if ::Kilt::TEMPLATES[ext] %}
|
||||
{{::Kilt::TEMPLATES[ext]}}({{filename}}, {{io_name}})
|
||||
{% else %}
|
||||
raise Kilt::Exception.new("Unsupported template type \"" + {{ext}} + "\"")
|
||||
{% end %}
|
||||
|
@ -27,4 +26,4 @@ module Kilt
|
|||
end
|
||||
end
|
||||
|
||||
::Kilt.register_template(".ecr", embed_ecr)
|
||||
::Kilt.register_template("ecr", embed_ecr)
|
||||
|
|
Loading…
Reference in a new issue