Table of Contents

Prototype: datastate()

Return type: data

Description: Returns the current evaluation data state.

The returned data container will have the keys classes and vars.

Under classes you'll find a map with the class name as the key and true as the value. Namespaced classes will be prefixed as usual.

Under vars you'll find a map with the bundle name as the key (namespaced if necessary). Under the bundle name you'll find another map with the variable name as the key. The value is converted to a data container (JSON format) if necessary. The example should make it clearer.

Mustache templates (see template_method), if not given a template_data, will use the output of datastate() as their input.


body common control
      bundlesequence => { holder, test };

bundle common holder
      "holderclass" expression => "any"; # will be global

      "s" string => "Hello!";
      "d" data => parsejson('[4,5,6]');
      "list" slist => { "element1", "element2" };

bundle agent test
      "state" data => datastate();

      # all the variables in bundle "holder" defined as of the execution of datastate() will be here
      "holderstate" string => format("%S", "state[vars][holder]");
      # all the classes defined as of the execution of datastate() will be here
      "allclasses" slist => getindices("state[classes]");

      "have_holderclass" expression => some("holderclass", allclasses);

      "holder vars = $(holderstate)";
      "I have the holder class";


R: holder vars = {"d":[4,5,6],"list":["element1","element2"],"s":"Hello!"}
R: I have the holder class

See also: getindices(), classesmatching(), variablesmatching(), mergedata(), template_method, mustache, inline_mustache, bundlestate()