teeplate
Version, currently 0.11.228 versions
- 0.11.2latestMay 26, 2021
- 0.11.1not indexedMay 26, 2021
- 0.11.0not indexedMay 26, 2021
- 0.10.1not indexedMay 26, 2021
- 0.10.0not indexedMay 26, 2021
- 0.9.0not indexedMay 26, 2021
- 0.8.0not indexedMay 26, 2021
- 0.7.0not indexedMay 26, 2021
- 0.6.1not indexedMay 26, 2021
- 0.6.0not indexedMay 26, 2021
- 0.5.0not indexedMay 26, 2021
- 0.4.5not indexedMay 26, 2021
- 0.4.4not indexedMay 26, 2021
- 0.4.3not indexedMay 26, 2021
- 0.4.2not indexedMay 26, 2021
- 0.4.1not indexedMay 26, 2021
- 0.4.0not indexedMay 26, 2021
- 0.3.0not indexedMay 26, 2021
- 0.2.3not indexedMay 26, 2021
- 0.2.2not indexedMay 26, 2021
- 0.2.1not indexedMay 26, 2021
- 0.2.0not indexedMay 26, 2021
- 0.1.4not indexedMay 26, 2021
- 0.1.4.1not indexedMay 26, 2021
- 0.1.3not indexedMay 26, 2021
- 0.1.2not indexedMay 26, 2021
- 0.1.1not indexedMay 26, 2021
- 0.1.0not indexedMay 26, 2021
github.com/amberframework/teeplate
A Crystal library for rendering multiple template files.
Installation
# Add this to your shard.yml
dependencies:
teeplate:
github: amberframework/teeplate
version: ~> 0.11.2Then run:
shards installshard.yml
- Crystal
>= 0.26.1, < 2.0.0- License
- MIT
- Author
- mosop
Dependencies
Runtime Dependencies
- future~> 1.0.0github: crystal-community/future.cr
Development Dependencies
- stdio~> 0.1.2github: mosop/stdiodev
- have_files~> 0.4.0github: mosop/have_filesdev
README
Teeplate
A Crystal library for rendering multiple template files.
Installation
Add this to your application's shard.yml:
dependencies:
teeplate:
github: mosop/teeplate
Supported Template Engines
- ECR
Usage
require "teeplate"
Example
Let's make our crystal init template.
Template structure
- spec/
- spec_helper.cr.ecr
- {{file}}_spec.cr.ecr
- src/
- {{file}}/
- version.cr.ecr
- {{file}}.cr.ecr
- {{file}}/
- .gitignore
- .travis.yml
- LICENSE.ecr
- README.md.ecr
- shard.yml.ecr
Template file example
# shard.yml.ecr
name: <%= @file %>
version: 0.1.0
authors:
- <%= @author %>
license: MIT
Template class definition
class CrystalInitTemplate < Teeplate::FileTree
directory "#{__DIR__}/path/to/template"
@file : String
@class : String
@author : String
@year : Int32
def initialize(@file, @class, @author, @year)
end
end
Here we go!
template = CrystalInitTemplate.new("teeplate", "Teeplate", "mosop", 2016)
template.render "/path/to/output"
Output structure
- spec/
- spec_helper.cr
- teeplate_spec.cr
- src/
- teeplate/
- version.cr
- teeplate.cr
- teeplate/
- .gitignore
- .travis.yml
- LICENSE
- README.md
- shard.yml
Output example
# shard.yml
name: teeplate
version: 0.1.0
authors:
- mosop
license: MIT
Overwriting
Forced
If a file already exists, Teeplate skips rendering the file. To force overwriting, set the :force option:
class Template < Teeplate::FileTree
directory "/path/to/template"
@face : String
def initialize(@face)
end
end
Template.new(":)").render("/path/to/output")
Template.new(":(").render("/path/to/output", force: true) # files may be overwritten
Template.new(":P").render("/path/to/output") # nothing happens
Interactive
If the :interactive option is true, Teeplate prompts us to select whether to overwrite an existing file.
shard.yml already exists...
overwrite(o)/keep(k)/diff(d)/overwrite all(a)/keep all(n) ?
Listing Rendered Files
You can print a list of rendered files. To enable it, set true to the :list option and call #render.
template = BrandNewCrystalInitTemplate.new("teeplate", "Teeplate", "mosop", 2017)
template.render "/path/to/overwrite", list: true
Output example:
modified .gitignore
identical .travis.yml
new Dockerfile
skipped LICENSE
skipped README.md
skipped shard.yml
modified spec/spec_helper.cr
skipped spec/teeplate_spec.cr
skipped src/teeplate/version.cr
skipped src/teeplate.cr
You can colorize the output by the :color option.
template.render "/path/to/overwrite", list: true, color: true
Want-to-do
- Merge on overwriting
Release Notes
- v0.3.0
- Quit on overwriting
- Rendering with append mode (see the issue)
- Teeplate::FileTree#render prints a list of rendered files with the :list option.
- v0.2.0
- (Breaking Change) FileTree#initialize does not receive an output directory. Instead, FileTree#render does.
- Diff on overwriting confirmation
- Overwrite All / Keep All on overwriting confirmation
- v0.1.3
- :interactive option to select whether to overwrite existing files
- v0.1.2
- :force option to overwrite output files if they exist
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.11.2- Tagged
- May 26, 2021
- Commit
d066b30cd8c5- Crystal
>= 0.26.1, < 2.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/amberframework/teeplate
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 28