{"action":"closed","issue":{"url":"https://api.github.com/repos/twigphp/Twig/issues/1278","labels_url":"https://api.github.com/repos/twigphp/Twig/issues/1278/labels{/name}","comments_url":"https://api.github.com/repos/twigphp/Twig/issues/1278/comments","events_url":"https://api.github.com/repos/twigphp/Twig/issues/1278/events","html_url":"https://github.com/twigphp/Twig/issues/1278","id":23186065,"number":1278,"title":"Implement parametrized extension","user":{"login":"curry684","id":1455673,"avatar_url":"https://avatars.githubusercontent.com/u/1455673?v=3","gravatar_id":"","url":"https://api.github.com/users/curry684","html_url":"https://github.com/curry684","followers_url":"https://api.github.com/users/curry684/followers","following_url":"https://api.github.com/users/curry684/following{/other_user}","gists_url":"https://api.github.com/users/curry684/gists{/gist_id}","starred_url":"https://api.github.com/users/curry684/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/curry684/subscriptions","organizations_url":"https://api.github.com/users/curry684/orgs","repos_url":"https://api.github.com/users/curry684/repos","events_url":"https://api.github.com/users/curry684/events{/privacy}","received_events_url":"https://api.github.com/users/curry684/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2013-11-23T11:51:49Z","updated_at":"2015-09-06T07:20:32Z","closed_at":"2015-09-06T07:20:32Z","body":"I frequently develop master templates that offer minor parametrization, for example to define certain classes or enable/disable optional blocks. As a practical stripped example:\r\n\r\nmaster-dialog.twig:\r\n\r\n```\r\n<form method=\"post\" action=\"...internal stuff...\">\r\n<fieldset class=\"content\">\r\n{% block content %}\r\n    <p>Override the 'content' block in your template to show content.</p>\r\n{% endblock %}\r\n</fieldset>\r\n{% if buttonbar is not defined or buttonbar %}\r\n<fieldset class=\"buttons\">\r\n{% block buttons %}\r\n    <button onclick=\"return Dialog.close()\" class=\"cancel\" type=\"button\">Cancel</button>\r\n{% endblock %}\r\n</fieldset>\r\n{% endif %}\r\n</form>\r\n```\r\n\r\nNow I can extend this template without a button bar underneath with:\r\n\r\n```\r\n{% extends 'master-dialog.twig' %}\r\n{% set buttonbar=false %}\r\n{% block content %}\r\n  <p>Alternative text</p>\r\n{% endblock %}\r\n```\r\n\r\nWhile it works fine this way, the syntax seems overly verbose, especially if you use this for multiple 'parameters'. Common programming languages also support parametrizing the constructor to tweak base class behaviour, so I suggest a similar syntax to embed and include for passing variables:\r\n\r\n```\r\n{% extends 'master-dialog.twig' with {'buttonbar': 'false'} %}\r\n```\r\n\r\nThis would not only be syntactic sugar since it also keeps the scope clearly limited to the base template."}}