tilt
Version, currently 1.0.03 versions
- 2.0.0latestFeb 17, 2016
- 1.1.0not indexedFeb 17, 2016
- 1.0.0not indexedFeb 17, 2016
github.com/makenowjust/tilt
TILT Is Loader of Template. It is generalized template engine interface.
Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
tilt:
github: makenowjust/tilt
version: ~> 1.0.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.0.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
tilt
Tilt Is Loader of Template. It is generalized template engine interface.
Installation
Add this to your application's shard.yml:
dependencies:
tilt:
github: MakeNowJust/tilt
Supported engines
- ecr - Embedded Crystal
- crustache - {{Mustache}} for Crystal
- slang - Slim-inspired templating language for Crystal
Usage
For users
require "tilt"
# Load template engines which are used in your app
require "ecr/macros"
require "crustache" # MakeNowJust/crustache
require "slang" # jeromegn/slang
# Render some templates
puts Tilt.render "hello.ecr" # render as "ecr"
puts Tilt.render "hello.mustache" # render as "mustache" (using crustache)
puts Tilt.render "hello.slang" # render as "slang"
# Set the default template engine
Tilt.default_engine "ecr"
puts Tilt.render "hello" # render as "ecr" although without extension
# Other APIs
# It is like `Tilt.render`, but it requires IO object then renders to this.
puts String.build { |io| Tilt.embed "hello", io }
# Load specified template file, and define `#to_s` method to render this file.
class HelloView
def initialize(@name); end
getter name
Tilt.file "hello"
end
puts HelloView.new("Tilt").to_s
# Passing additional arguments to the template if the engine supported
puts Tilt.render("hello.mustache", { "name" => "Tilt" })
# Add your template engine
Tilt.register "html", ECR.embed
# Add alias
Tilt.alias "html", "ecr"
For developer of template engine
This is the process of Tilt.embed.
- There are
<FilenameExtension>.embedmacro in global space. (<FilenameExtension>is your template engine's filename extension. When it is less then 4 character, it should be upper case. Otherwise, when it is more than or equal 4 character,it should be camel-case.) - When
Tilt.embed(filename)is called,Tiltcalls<FilenameExtension>.embedor registered engine iffilenamehas extension. Otherwise,Tiltcalls default engine.
require "tilt"
module FMT
# Render `filename` by `sprintf`
def self.embed(filename, io, arg = nil)
io << sprintf(File.read(filename), arg)
end
end
# Render with `FMT` template engine
puts Tilt.render "hello.fmt", { "name" => "Tilt" }
If you create new template engine supported Tilt, I welcome your Pull Request to add it to supported engine list. (And, I wanna you add specs for this engine.)
Development
$ crystal spec
Contributing
- Fork it ( https://github.com/MakeNowJust/tilt/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- @MakeNowJust TSUYUSATO Kitsune - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- Feb 17, 2016
- Commit
889a0470427d- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/makenowjust/tilt
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 3