karver-0.1.2: A simple template engine, inspired by jinja2

CopyrightJeremy Hull 2013
LicenseBSD3
MaintainerJeremy Hull <sourdrums@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell98

Text.Karver.Types

Description

Base types used throughout Karver.

Synopsis

Documentation

data Token Source

When dealing with the syntax of karver, we first translate the given Text into Tokens for easier manipulation. Each Token type is a representation of a certain type of data.

Constructors

LiteralTok Text

Literal token. This is the default Token that gets matched only if it isn't any of the others.

IdentityTok Text

Identity token. This is for a regular variable with no sign of it being an object or list. eg. {{ ident }}

ObjectTok Text Text

Object token. This is similar to IdentityTok, but if there is a dot, it gets placed in the second value. The first Text is the object name, while the second Text is the key to the object. eg. {{ ident.key }}

ListTok Text Int

List token. This is also similar to the IdentityTok, but if there is an opening square bracket, it gets place in the second value. Text is the list name, while Int is the index. eg {{ ident[4] }}

ConditionTok Text Text Text

If statement token. The first Text will be the check if a identity is available or not. Second Text is the body of the if statement. And the third Text is the else body — if their isn't one, it will be empty.

LoopTok Text Text Text

For loop token. The first Text is the list that will be iterated over. Second Text is the variable name a single element of the list will be placed into. Third Text is the body of the loop that will be repeatedly translated from.

IncludeTok Text

Include token. The Text value store a file name, which includes its relative path, based on the current working directory.

Instances

data Value Source

Fairly basic work around for using different types inside a HashMap. The Value type also make it possible for List to contain more than one type.

Constructors

Literal Text

The base value for the storing of variable.

Object (HashMap Text Text)

An alias for HashMap, that will only hold Text with Text as a key as well.

List (Vector Value)

An alias for Vector, that can hold all three Values — which isn't desirable, because their can be nested Lists.