Esempio n. 1
0
 /**
  * Decorates a content with a template.
  *
  * <pre>
  * <p:decorate
  *     with = string>
  *     <!-- Content: p:with-param*, template -->
  * </p:decorate>
  * </pre>
  *
  * The content of the markup is rendered to create the component to decorate, it is then passed
  * to the decorating template as the `component` variable.
  *
  * The name of the decorating template is specified with the `with` attribute, and is
  * interpolated e.g. if "page" is specified the template name "@page" is used; if "admin/page"
  * is specified the template name "admin/@page" is used.
  *
  * The parameters specified using `with-param` are all turned into variables.
  *
  * Example:
  *
  * <pre>
  * <p:decorate with="page">
  *     <p:page:content id="body" />
  * </p:decorate>
  * </pre>
  *
  * @param array $args
  * @param Engine $engine
  * @param mixed $template
  *
  * @return string
  */
 public static function markup_decorate(array $args, Engine $engine, $template)
 {
     $template_name = $args['with'];
     $rendered_template = $engine($template);
     unset($args['with']);
     $engine->context['component'] = $rendered_template;
     foreach ($args as $name => $value) {
         $engine->context[$name] = $value;
     }
     return $engine->callTemplate(TemplateName::from($template_name)->as_layout, $args);
 }