Skip to content

Function_plugin

miroshnikov edited this page Mar 27, 2015 · 1 revision

Function plugin

All attributes passed to template functions from the template are contained in the params object.

data is an object passed to fetch().

  • Register plugin
   jSmart.prototype.registerPlugin(
      'function', 
      'sayHello', 
      function(params, data)
         {
            var s = 'Hello ';
            if ('to' in params)
            {
               s += params['to'];
            }
            return s;
          }
      );
  • Use in the template
   {sayHello to='Everybody'}
  • The result would be
   Hello Everybody
Clone this wiki locally