Newscoop 4 Cookbook

Language elements and conventions

In the following chapters describing the template language the following conventions are used:

  • identifiers in between '<' and '>' must be replaced in the template according to their description
  • spaces must be used as in the language description
  • identifiers that are not in between '<' and '>' are language keywords and must be written as in the language description
  • identifiers enclosed by '[' and ']' characters are not mandatory in the statement
  • sequences of identifiers separated by '|' character describe a situation where all the identifiers are valid but only one can be used at a time

The template language is composed of:

  • statements: keywords with a special meaning that define actions taken by the template parser
  • parameters: keywords describing statement features; they are used to specify statement constraints
  • parameter values: keywords that describe the parameter that must be taken

Any value must be put in between double quotes (""). The double quote must be escaped any time it is used in an identifier. For example, escaping a value that contains a quote:

{{ if $gimme->article->name == "Lucas \"the beast\"" }} 

In some statements (usually lists) there is a special parameter named "constraints". This parameter describes conditions that cannot be specified in the usual way:

parameter="value" 

Instead, constraints are specified in the following way:

constraints="<constraints_list>" 

Constraints are built from the following expressions:

  • comparison expressions: <attribute> <operator> <value>
  • attributes without type: <attribute>

Attributes may have no type, or one of the following types:

  • integer: signed, 10 digits number
  • string of characters: may contain any character except control characters - these will be removed automatically
  • switch: has two values: "on" and "off"
  • date: year, month, day; where the date value is specified it must be written in "yyyy-mm-dd" format
  • time: hour, minute, second; where the time value is specified it must be written in "hh:mm:ss" format
  • datetime: year, month, day, hour, minute, second; where the datetime value is specified it must be written in "yyyy-mm-dd hh:mm:ss" format
  • topic: list of names defined by the Newscoop user for categorizing articles

Every type has a list of valid operators that can be used on attributes of that particular type. The operators list corresponding to defined types is:

  • integer: <integer_operator> = is | not | greater | greater_equal | smaller | smaller_equal
  • string of characters: <string_operator> = is | not | greater | greater_equal | smaller | smaller_equal
  • switch: <switch_operator> = is | not
  • date: <date_operator> = is | not | greater | greater_equal | smaller | smaller_equal
  • time: <time_operator> = is | not | greater | greater_equal | smaller | smaller_equal
  • datetime: <datetime_operator> = is | not | greater | greater_equal | smaller | smaller_equal
  • topic: <topic_operator> = is | not

Spaces in values must be escaped with backslash, for example:

constraints="topic is Global\ Warming:en" 

In this case, "Global Warming" is the topic name.