Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
add unwiredcouch style project page
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtazz committed Jun 14, 2014
1 parent 165922d commit 33861e4
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "_layouts"]
path = _layouts
url = git://github.com/mrtazz/jekyll-layouts.git
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
gaugesid: 4f80d7c5613f5d3789000001
projecturl: https://github.com/mrtazz/plustache
basesite: http://www.unwiredcouch.com
markdown: kramdown
1 change: 1 addition & 0 deletions _layouts
Submodule _layouts added at d8af58
136 changes: 136 additions & 0 deletions index.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,136 @@
---
layout: project
title: plustache
---

# plustache - mustache templates for C++
Basic port of [mustache templating](http://mustache.github.com) to C++.

## Motivation
I just wanted to port mustache and build simple templating for C++.
And I am still trying hard to keep it simple.

## Usage

### Simple Usage
Create a template:

{% highlight html %}
<h1>{{ "{{ title " }}}}</h1>
Hi I am {{ "{{ name " }}}}.
I like {{ "{{ thing " }}}}.
{% endhighlight %}

Fill the context:

{% highlight c++ %}
ObjectType ctx;
ctx["title"] = "About";
ctx["name"] = "Daniel";
ctx["thing"] = "turtles";
{% endhighlight %}

Instantiate template class and render the template:

{% highlight c++ %}
template_t t;
string result = t.render(template, ctx);
{% endhighlight %}

Result:

{% highlight html %}
<h1>About</h1>
Hi I am Daniel.
I like turtles.
{% endhighlight %}

### Advanced Usage
Create the template:

{% highlight html %}
<h1>{{ "{{ title " }}}}</h1>
<ul>
{{# friends}}
<li> {{ "{{ name " }}}}</li>
<li> {{ "{{ job " }}}}</li>
<li> {{ "{{ status " }}}}</li>
{{/ friends}}
</ul>
{% endhighlight %}

Create the context:

{% highlight c++ %}
// create types
context ctx;
CollectionType c;
ObjectType jim;
ObjectType john;
ObjectType jack;
// Fill values
ctx.add("title", "My friends");
jim["name"] = "Jim";
jim["job"] = "Wizard";
jim["status"] = "Eating";
john["name"] = "John";
john["job"] = "Rainbow Painter";
john["status"] = "Sleeping";
jack["name"] = "Jack";
jack["job"] = "Unicorn Trainer";
jack["status"] = "Riding";
// enter data
c.push_back(jim);
c.push_back(john);
ctx.add("friends", c);
// also possible
ctx.add("friends", jack);
{% endhighlight %}

Render the template:

{% highlight c++ %}
template_t t;
string result = t.render(template, ctx);
{% endhighlight %}


## Installation
Clone this repository:

{% highlight bash %}
git clone git://github.com/mrtazz/plustache.git
{% endhighlight %}

Run the install tasks:

{% highlight bash %}
autoreconf -i
./configure
make
make install
{% endhighlight %}

Or you can get it via [homebrew](http://github.com/mxcl/homebrew):

{% highlight bash %}
brew install plustache
{% endhighlight %}

## Supported Functionality (as described in [the man page](http://mustache.github.com/mustache.5.html))
* Variables
* Sections
* False Values/Empty Lists
* Non-Empty-Lists
* Inverted Sections
* Comments
* Partials
* Set Delimiter
* HTML escape syntax (triple mustaches)

## TODO
* plustache executable

## Dependencies
* boost for regex and some other things
* google test for unit testing

0 comments on commit 33861e4

Please sign in to comment.