fcf.tokenize() function
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Performs tokenization of the given string. The control constructs of the tokenizer are @{{...}}@ and !{{...}}!.
When tokenizing the input string, control constructs are expanded.
-
Single line Javascript command control structure
This type of computed construct contains a single-line Javascript command placed in an @{{...}}@ block. Inside this block, only single-line JS operations are allowed, which do not write data and cannot lead to execution hang, i.e. select operation ( CMP ? ARG1 : ARG2 ) and arithmetic operations are allowed. Also, only safe functions that do not write data are available. Access to global variables is implemented only for constants from Math and fcf objects. This approach is implemented only on the server side; on the browser side, the usual
eval () call is performed.How to add permission to execute additional functions and methods is described on the tokenization mechanism description page: tokenization.
-
Translation insertion construct
This construction translates a substring enclosed in a !{{...}}! block. Substring translation is carried out by system means of the framework (function
fcf.t ()). If the translation for the given substring is not found, then the original substring from the !{{...}}! construction is returned to the resulting string.Inside the !{{...}}! it is allowed to place the @{{...}}@ construction, which allows to form translatable strings with changing data.
-
boolean quiet =false - If the argument isfalse then an error is thrown exception.If the argument is
true , then the @{{...}}@ constructs in which an error occurred are passed to the resulting string without calculation of the result (the @{{...}}@ construct is passed as it was passed to the function). -
string" result ="string" - If the option is"string" , then the function always returns a string as its result.If the option is
"auto" , then if the input string contains only the @{{...}}@ construct, without additional characters, the function will return the original result of the @{{...}}@ construct evaluation, if the input string contains additional characters, then the function will return a string representation.
Output:
Output:
Output: