Additional available options:
Overrides FragmentRendererInterface::render
public function render($uri, Request $request, array $options = array()) {
if ($uri instanceof ControllerReference) {
if (null === $this->signer) {
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
}
$uri = $this->signer
->sign($this
->generateFragmentUri($uri, $request));
}
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
$uri = str_replace('&', '&', $uri);
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
if (null !== $this->templating && $template && $this
->templateExists($template)) {
$content = $this->templating
->render($template);
}
else {
$content = $template;
}
$attributes = isset($options['attributes']) && is_array($options['attributes']) ? $options['attributes'] : array();
if (isset($options['id']) && $options['id']) {
$attributes['id'] = $options['id'];
}
$renderedAttributes = '';
if (count($attributes) > 0) {
foreach ($attributes as $attribute => $value) {
$renderedAttributes .= sprintf(' %s="%s"', htmlspecialchars($attribute, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false), htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false));
}
}
return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content));
}