teeplate

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

Teeplate

A Crystal library for generating files from templates.

Build Status

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
  • .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
  • .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

  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.1
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