teeplate
Teeplate
A Crystal library for generating files from templates.
Installation
Add this to your application's shard.yml
:
dependencies:
teeplate:
github: mosop/teeplate
Features
File Tree Template
Template directory structure
- spec/
- .gitignore
- spec_helper.cr.ecr
- {{file}}_spec.cr.ecr
- src/
- {{file}}/
- version.cr.ecr
- {{file}}.cr.ecr
- {{file}}/
- .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(out_dir, @file, @class, @author, @year)
super out_dir
end
end
Here we go!
CrystalInitTemplate.new("/path/to/output", "teeplate", "Teeplate", "mosop", 2016).render
Output directory structure
- spec/
- .gitignore
- spec_helper.cr
- teeplate_spec.cr
- src/
- teeplate/
- version.cr
- teeplate.cr
- teeplate/
- .travis.yml
- LICENSE
- README.md
- shard.yml
Output file example
# shard.yml
name: teeplate
version: 0.1.0
authors:
- mosop
license: MIT
Usage
require "teeplate"
and see Features
Wish List
- Confirmation (Overwrite, Abort, Ignore...)
Contributing
- Fork it ( https://github.com/mosop/teeplate/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
- mosop - creator, maintainer