argon 0.0.1

Argon html template rendering library.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Argon

Argon is a simple compiled HTML text macro language, with a focus on minimalism and readability. It was created out of frustration using vibe.d's Diet Templates. Argon is simple to use, in that it is does not try to abstract over HTML syntax, rather it provides a simple to use text interpolation system, which can easily integrate into existing data structures.

Features:

  • Namespaces - All elements require a namespace to access a data structure from, so it is easy to put multiple data structures in one page.
  • Lists - Lists allow for iteration over data structures which can be iterated with foreach, along with arbitrary bits of HTML, other elements and nested lists.
  • Compiled - Argon templates compile down to D code, for maximum efficiency.
  • Includes - Argon templates can include each other, and included templates have full access to all of the main templates namespaces.

TODO:

  • White Space Control - Better white space control for argon templates.
  • Include Indenting - Support for indenting HTML source in included templates.
  • Dynamic Render - Support for dynamic rendering of Argon templates.
  • Conditional Rendering - Support for conditional rendering of parts of Argon templates.
  • Automatic Encoding - Support for automatic encoding of elements to HTML escape sequences.

Example:

The Following is an example of how to use an Argon template. See the examples directory for further details.

test.argon:

<!DOCTYPE html>
<html>
  <head>
    <title>{element=content:hello_world}</title>
  </head>
  <body>
    <h1>{element=content:hello_world}</h1>
    <ul>
    {list=content:list}
      <li>list index: '{element=content:list[#]}', list value: '{element=content:list[$]}'</li>
    {/list}
    </ul>
  </body>
 </html>

test.d:

import std.stdio;
import argon.argon;

struct Content
{
  string hello_world = "Hello, World!";
  string[] list = ["alpha", "beta", "gamma", "delta"];
}

void main()
{
  Content content;
  stdout.renderArgonTemplate!("test.argon", "content", content)();
}
Authors:
Sean Campbell
Dependencies:
none
Versions:
0.0.1 2017-Oct-22
~master 2017-Nov-13
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 3 downloads this month

  • 5 downloads total