**Warning**: This project has been flagged as _absolute trash_ by it's creator. While he does have the power to destroy it, he wishes to show mercy and let it hang out as a reminder that some ideas are bad and just don't pan out. Superceeded ideologically by [arcana](http://frankiebaffa.com/software/arcana.html). > _Use Very Good Templating Engine for all of your templating needs. Or do not. > I am not a beggar._ > - **Ron Swanson**, _Parks and Recreation_ ## Installation ### From Source To install from source, you must have `git` and `cargo` installed. ```bash git clone "https://github.com/frankiebaffa/very-good" NAME cd NAME cargo install --path vgc cargo install --path vgd ``` ## Crates ### vg-core The core functionality of the templating engine. ### vgc The command-line compiler. ### vgd A command line deployment program driven by a configuration file. Useful for moving/compiling files in bulk to a distribution/deployment directory. ## Documentation ### Templates A `vg` template is just a text file. A template can contain **variables** (ex: `{{ text }}`), **tags** (ex: `{% block body %}{% endblock body %}`), **comments** (ex: `{# a comment #}`), and **content**. Variables are placeholders waiting to be replaced by the output of tags. Tags can define content and control the flow of a document. Comments are completely ignored. Content is everything else that is not recognized by the parser. ```htmldjango
Here is a paragraph defined by the child-template!
{%- endblock %} ``` If this child-template were compiled using `vgc`, still assuming that nothing exists within the `/objects/sections` directory, the following would be the output: ```htmlHere is a paragraph defined by the child-template!
``` ### Tags Defined as `{% keyword [...] %}`. #### Ignore ```htmldjango {% ignore %} ``` Instructs the parser to ignore the file entirely. If used on a page it will return an error. `vgd` will handle this error peacefully and gives the optional functionality of deleting the destination file when the source is ignored. If found in an included file or a for-loop item, the file will be ignored. ##### Constraints - Must be the first definition of the file, else will be handled as content. - All subsequent `ignore` tags will be handled as content, which shouldn't be an issue given the file is ignored. #### Extends ```htmldjango {% extends "{{ item.text }}
{% else %}{{ item }}
{% endif %} {% else %}No items.
{% endfor %} ``` ```htmldjango {% for item in "{{ item.text }}
{% else %}{{ item }}
{% endif %} {% else %}No items.
{% endfor %} ``` Clones the inner content and implements for the specified file or for each file in the specified directory. If the file(s) found extend another template, then the file will be completely compiled before handling the inner content. ### Variables Defined as `{{ NAME }}`. Variables expect to be implemented by tags. The output of the variable's implementation can be augmented with [filters](#variable_filters). If a variable is not wrapped in an `if` block checking for it's existence, then its definition will be included in the output when it is not implemented. #### Nullability Variables can be defined as nullable by succeeding the name with a question-mark. This is effectively syntactic-sugar for wrapping the variable in an if block with an exists condition. Consider the following file at `/page.jinja`: ```htmldjango {{ text? }} ``` If this file was compiled, its output would be blank. #### Filters Filters modify the content implementing the variable. They can be triggered by using a pipe after a variable name. ```htmldjango {% block text %} Here is some text. And here is some more. {% endblock %} {{ text | detab | flatten | trim }} ``` This example would compile to the following. ```html Here is some text. And here is some more. ``` ##### Flatten Replaces all newlines with spaces. ##### Detab Removes all tabs. ##### Trim Trims the start and end of the content. ##### Upper Makes the content uppercase. ##### Lower Makes the content lowercase. ##### Replace ```htmldjango {{ item | replace " " "_" }} ``` Replaces the first quoted item with the second. ##### Md ```htmldjango {{ item | md }} ``` Parses the item from No-Flavor markdown to html. ### Comments Defined as `{# CONTENT #}`. Comments are ignored after the initial parsing pass. ### Tricks #### Meta Paths Consider the following template at `/objects/template.jinja`. ```htmldjango {% for item in "{{ item-directory }}" %} {{ item }} {% endfor %} ``` The **variable** found within the `PATH` portion of the for-tag definition can be templated in a single pass of the compiler to allow for dynamic extends, loops, and inclusions.