TokenRange

split the input into tokens

Constructors

this
this(string tpl)

Members

Functions

empty
bool empty()
front
Token front()
popFront
void popFront()

Static functions

opCall
opCall(string tpl)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

It should parse a token value

enum tpl = "{{value}}";

auto range = TokenRange(tpl);

range.front.should.equal(Token(Token.Type.value, "value", Properties("")));

It should parse an helper token

enum tpl = "{{helper value}}";

auto range = TokenRange(tpl);

range.front.should.equal(Token(Token.Type.helper, "helper", Properties("value")));

It should parse block tokens

enum tpl = "{{#if condition}}{{else}}{{/if}}";

auto range = TokenRange(tpl);

range.array.should.equal([
  Token(Token.Type.openBlock, "if", Properties("condition")),
  Token(Token.Type.value, "else", Properties("")),
  Token(Token.Type.closeBlock, "if", Properties(""))]);

It should parse two value tokens

enum tpl = "{{value1}}{{value2}}";

auto range = TokenRange(tpl);

range.array.should.equal([
  Token(Token.Type.value, "value1", Properties("")),
  Token(Token.Type.value, "value2", Properties(""))]);

It should parse value and text tokens

enum tpl = "1{{value1}}2{{value2}}3";

auto range = TokenRange(tpl);

range.array.should.equal([
  Token(Token.Type.plain, "1", Properties("")),
  Token(Token.Type.value, "value1", Properties("")),
  Token(Token.Type.plain, "2", Properties("")),
  Token(Token.Type.value, "value2", Properties("")),
  Token(Token.Type.plain, "3", Properties(""))]);

Meta