compiler.assign.php 968 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * Smarty {assign} compiler function plugin
  9. *
  10. * Type: compiler function<br>
  11. * Name: assign<br>
  12. * Purpose: assign a value to a template variable
  13. * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
  14. * (Smarty online manual)
  15. * @param string containing var-attribute and value-attribute
  16. * @param Smarty_Compiler
  17. */
  18. function smarty_compiler_assign($tag_attrs, &$compiler)
  19. {
  20. $_params = $compiler->_parse_attrs($tag_attrs);
  21. if (!isset($_params['var'])) {
  22. $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING);
  23. return;
  24. }
  25. if (!isset($_params['value'])) {
  26. $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING);
  27. return;
  28. }
  29. return "\$this->assign({$_params['var']}, {$_params['value']});";
  30. }
  31. /* vim: set expandtab: */
  32. ?>