teeplate

A library for rendering multiple template files
0.1.0 released
mosop/teeplate
16 13 2
mosop

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

  • /path/to/template/
    • spec/
      • .gitignore
      • spec_helper.cr.ecr
      • {{file}}_spec.cr.ecr
    • src/
      • {{file}}/
        • version.cr.ecr
      • {{file}}.cr.ecr
    • .travis.uml
    • 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 "/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/repo", "teeplate", "Teeplate", "mosop", 2016).render

Output directory structure

  • /path/to/template/
    • spec/
      • .gitignore
      • spec_helper.cr
      • teeplate_spec.cr
    • src/
      • teeplate/
        • version.cr
      • teeplate.cr
    • .travis.uml
    • LICENSE
    • README.md
    • shard.yml

Output 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

  1. Fork it ( https://github.com/mosop/teeplate/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • mosop - creator, maintainer
teeplate:
  github: mosop/teeplate
  version: ~> 0.1.0
License MIT
Crystal none

Authors

Dependencies 1

  • have_files ~> 0.2.1
    {'github' => 'mosop/have_files', 'version' => '~> 0.2.1'}

Development Dependencies 0

Dependents 2

Last synced .
search fire star recently