invoke() public method

Invoke the filter that matches given name
public invoke ( string $name, mixed $value, array $args = null ) : string
$name string The name of the filter
$value mixed The value to filter
$args array Additional arguments for the filter
return string
Ejemplo n.º 1
0
 function test_add_filter()
 {
     $context = new LiquidContext();
     $context->add_filters(new HiFilter());
     $this->assertEqual('hi? hi!', $context->invoke('hi', 'hi?'));
     $context = new LiquidContext();
     $this->assertEqual('hi?', $context->invoke('hi', 'hi?'));
     $context->add_filters(new HiFilter());
     $this->assertEqual('hi? hi!', $context->invoke('hi', 'hi?'));
 }
Ejemplo n.º 2
0
 /**
  * Renders the variable with the data in the context
  *
  * @param LiquidContext $context
  */
 function render($context)
 {
     $output = $context->get($this->_name);
     foreach ($this->_filters as $filter) {
         list($filtername, $filterArgKeys) = $filter;
         $filterArgValues = array();
         foreach ($filterArgKeys as $arg_key) {
             $filterArgValues[] = $context->get($arg_key);
         }
         $output = $context->invoke($filtername, $output, $filterArgValues);
     }
     return $output;
 }
Ejemplo n.º 3
0
 /**
  * Renders the tag
  *
  * @param LiquidContext $context
  */
 public function render(&$context)
 {
     $output = $context->get($this->_from);
     foreach ($this->filters as $filter) {
         list($filtername, $filter_arg_keys) = $filter;
         $filter_arg_values = array();
         foreach ($filter_arg_keys as $arg_key) {
             $filter_arg_values[] = $context->get($arg_key);
         }
         $output = $context->invoke($filtername, $output, $filter_arg_values);
     }
     $context->set($this->_to, $output);
 }
Ejemplo n.º 4
0
 /**
  * Renders the variable with the data in the context
  *
  * @param LiquidContext $context
  */
 function render($context)
 {
     $output = $context->get($this->name);
     //debug('name', $this->name, 'output', $output);
     foreach ($this->filters as $filter) {
         list($filtername, $filter_arg_keys) = $filter;
         $filter_arg_values = array();
         foreach ($filter_arg_keys as $arg_key) {
             $filter_arg_values[] = $context->get($arg_key);
         }
         $output = $context->invoke($filtername, $output, $filter_arg_values);
     }
     return $output;
 }