Allow to set id + custom attributes to hinclude tag

Squashed commits:
Allow to set an id attribute to hinclude tag
Allow custom attributes on hinclude tag
This commit is contained in:
Mike Meier 2013-03-20 15:33:28 +01:00 committed by Jean-François Simon
parent e8b7f0fd34
commit 342d08967c

View File

@ -93,7 +93,13 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
$content = $template;
}
return new Response(sprintf('<hx:include src="%s">%s</hx:include>', $uri, $content));
$attrOptions = isset($options['attr']) && is_array($options['attr']) ? $options['attr'] : array();
$attributes = array();
foreach($attrOptions as $attribute => $value) {
$attributes[] = sprintf('%s="%s"', $attribute, $value);
}
return new Response(sprintf('<hx:include src="%s" %s>%s</hx:include>', $uri, implode(" ", $attributes), $content));
}
private function templateExists($template)