Giter Club home page Giter Club logo

glitter2's Introduction

glitter

Template Processing

Goal

With glitter I tried to create a template processor which enables the user to create flexible, configurable templates.

This is a complete rewrite of the original ruby glitter in rust with some new features and YAML as base format for configuration files.

File Structure

Each glitter processing file is a YAML that consists of up to four top-level parts:

  • global
  • local
  • injection
  • template

The global, local and injection parts are similar to each other - as all of them define variables that can be used in other places. But they differ in accessibility and scope:

  • injection: The variables defined in injection are the only directly accesible from the template. Different to global and local this is not a dictionary/hash but an array of dictionary/hash. There can be multiple iterations defined - but at least one is necessary.
  • local: See this as your workbench. You can define multiple variables either directly or by importing/loading/rendering other files. In the injection block you can then selectivly access those variables you need from your local storage
  • global: Basically this is very similar to the local storage, only it is only run on the top-most glitter file. Global definitions on sub-files run using render are ignored. And all variables defined in global are accessible in all sub-files (load & render), while local-defined variables need to be passed along explicitly.

Template Definition

The template block can either be one string, which then is processed as often as there are injections. Alternatively you can define a header, body and footer which can all either be direct value definitions or file quotes.

The value replacement searches for either *{x} constructs, which then applies the value of variable x in that place - or via *> the rest of the line is taken as variable name and replaced accordingly.

Lazy Evaluation

All variable declarations are not processed directly when found, but only the definition is stored. Only when the variables value is actively accessed (either by using a sub-variable or by printing it into the output) is the variable actually interpreted.

Beware: A side effect of this is, that the same evaluation can happen multiple times. This might change in a later version.

How To

A real How-To/Manual will be written, but the example files in the example-subfolder give already an impression what glitter is able to do.

glitter2's People

Contributors

dependabot[bot] avatar kelko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.