Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for render_pagetemplate() #142

Merged

Conversation

tentwofour
Copy link
Contributor

  • Merge passed parameters with the current twig context - allows passing of view variables when calling render_pagetemplate()
  • Argument was previously unused

 - Merge passed parameters with the current twig context - allows passing of view variables when calling render_pagetemplate()
 - Argument was previously unused
@tentwofour
Copy link
Contributor Author

Not sure if I'm missing another way to do this, but calling

render_pagetemplate(page, { 'customVariable': 'myGreatValue' }

wasn't passing customVariable to my page template.

Not sure why the argument is available, but not merged with the Twig context in the extension - if I'm missing something obvious, let me know :)

@@ -72,7 +72,7 @@ public function renderPageTemplate(array $twigContext, HasPageTemplateInterface

$template = $this->environment->loadTemplate($pageTemplate->getTemplate());

return $template->render($twigContext);
return $template->render(array_merge($twigContext, $parameters));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to put $parameters as the first element. The keys from the first array will be preserved. If an array key exists in both arrays, then the element from the first array will be used and the matching key's element from the second array will be ignored.

krispypen added a commit that referenced this pull request Feb 17, 2015
@krispypen krispypen merged commit 7a54ed0 into Kunstmaan:master Feb 17, 2015
@roderik roderik modified the milestones: Q2 2015 - v3.2, Q1 2015 - v3.1 Feb 28, 2015
@roderik roderik modified the milestones: 3.1.0, 3.0.2 Apr 10, 2015
@tentwofour tentwofour deleted the bugfix_pagetemplatetwigextension branch October 26, 2015 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants