Basic Usage

K2HR3 Template Engine

Dynamic RESOURCE can be defined for RESOURCE of K2HR3 system.
The K2HR3 system provides a TEMPLATE notation for defining dynamic RESOURCE.
The contents described in this TEMPLATE pass through the K2HR3 Template Engine and are expanded as RESOURCE data. The K2HR3 Template Engine and TEMPLATE notation are described below.

Apply

In the K2HR3 system, USER can set a character string as RESOURCE data.
For character strings set as RESOURCE, USER and ROLE member HOST can be read.
The K2HR3 Template Engine can expand template strings that satisfy the TEMPLATE notation.

Overview

Explain the description method and specification of the basic TEMPLATE to be understood by the K2HR3 Template Engine.

Analysis range of TEMPLATE

The K2HR3 Template Engine analyzes and expands the character string of the range(statement) separated by the following keywords in the character string read as a TEMPLATE.

{{ .... }}

Specifying the template engine

This feature is reserved and currently only fixed value “k2hr3template”(for K2HR3 Template Engine) is supported.

This is a statement specified by the template engine.
It must start from the beginning of all TEMPLATE strings.
You can omit it when using the K2HR3 Template Engine.

Comment

Statements as described below will not be output(displayed) when expanded by the template engine.
It is a statement to use as a general comment.

{{# This is comment strings.... }}

Display variables

By describing as follows, you can display values such as variables (described later) used in the template.
You can also specify constants for variables to be displayed.

{{= 'print static string' }}
{{= true }}
{{= 1000 }}
{{= %variable% }}

Escape keyword

You may not want to recognize the keywords used to specify the analysis range of the template as a template.
Also, you may not want to recognize the keywords used to specify the character string (described later) as a template.
These escaping methods are shown below.

Constant

The constants supported by the K2HR3 Template Engine are shown below.

Number

There are the following methods for expressing numerical values supported by the K2HR3 Template Engine.

String

To describe a character string in a statement, specify the range with single quote or double quote.

'This is string in single quote'
"This is string in double quote"

Variable

When analyzing the template, the K2HR3 Template Engine permanently uses the variables of each template to be expanded.
A variable has one of the following forms.

%variable%
%var_array%[0]
%var_object%{'key'}

Currently, multi-level array and objects are not supported.

You can freely define variables in templates.
Alternatively, you can specify the YRN path of RESOURCE, ROLE registered in the K2HR3 system, and use the data set for these as variables.

%yrn:yahoo:yjcore:::resource:k2hr3api_res%

Syntax

The control syntax available for the K2HR3 Template Engine is shown below.

Operator

Enumerate available operators. Conditional operators are mainly used as conditional statements of control syntax.

Attention 1

Variables and constants basically have types (numbers, strings, logical values).
When binary operators specify variables and constants of different types, they are aligned to the type on the left side as much as possible.

Attention 2

Operator priorities follow general priorities.
The result of expanding the following template is “20”.

{{ %tmp_priority_data00% = 1 + 3 * 2 * 3 + 1 }}
{{= %tmp_priority_data00% }}

Samples

The sample template character string (multiple lines) is shown below.

{{#!k2hr3template }}
{{# COMMENT LINE : The above line can be omitted. }}
Example of template expansion.

1) Examples of loops using variables
  {{ for %val% = 0 ; %val% < 2 ; ++%val% }}
    - Expansion within a loop: The value of the current variable {{= %val% }}.
  {{ done }}

3) Calculation
  {{ %val% = 10 + 10 * 9 / 3 }}
  %val% should be 40.
 Calculation result = {{= %val% }}

That 's all.

The following shows the result of expansion of the above template character string by the K2HR3 Template Engine.
Line feeds are adjusted

Example of template expansion.

1) Examples of loops using variables
    - Expansion within a loop: The value of the current variable 0.
    - Expansion within a loop: The value of the current variable 1.

3) Calculation
  %val% should be 40.
 Calculation result = 40

That 's all.
Basic Usage