Skip to content

achin/lein-mustache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lein-mustache

This plugin evaluates Mustache templates using the Clostache library. This library is in development and has been tested with Clojure 1.3.0 and Leiningen 2.0.0-preview10.

Installation

lein-mustache is available as a plugin. So, add this to your ~/.lein/profiles.clj:

{:user {:plugins [[lein-mustache "0.2"]]}}

Or you can include it in your project.clj:

{:profiles {:dev {:plugins [[lein-mustache "0.2"]]}}}

Use

To evaluate a Mustache template in file, template, with Clojure data in file, data, type this:

$ lein mustache template data

To evaluate Mustache templates listed in project.clj with Clojure data in file data, include a key :mustache in project.clj. The corresponding value is a sequence of maps, each containing a :template-path and :destination-path.

Then, invoke lein mustache without the template argument,

$ lein mustache data

Destinations for evaluated templates may themselves be templates,

Example

If resources/hello.mustache in your Leiningen project contains the following:

Hello, {{name}}, welcome to {{system}}.

And resources/data.clj contains:

{:name "Alex"
 :system "Your Computer"}

Then running

lein mustache resources/hello.mustache resources/data.clj

Will output

Hello, Alex, welcome to Your Computer.

If project.clj contains a :mustache entry,

:mustache [{:template-path "resources/hello.mustache"
            :destination-path "target/hello.txt"}]

Then running

lein mustache resources/data.clj

Will create the file target/hello.txt with the same contents as above.

Contributors

Alex Chin Charles Simpson John Stoneham

About

Evaluate a Mustache template in Leiningen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •