Files
2012-02-21 01:15:00 -05:00

1 line
2.6 KiB
JSON

[{"user_id": 30572, "stars": [], "topic_id": 39875, "date_created": 1308583477.831085, "message": "Hi\n\nI'm looking for a way of doing this :\n\nI have two templates \"base.html\" and \"mobile.html\", these two are very different, and, following DRY, i added a \"meta.html\" template which is included (via \"include\") in the two first.\n\nIn this \"meta.html\" i have things like \n\n<meta property=\"og:title\" content=\"{% block opengraph_title %}Foo bar !{% endblock %}\" />\n\nNow, for a page i have a template \"mypage.html\", which extends \"base.html\" (via \"extends\") and in it i want to override the \"opengraph_title\" block, so i add\n\n{% block opengraph_title %}My Page !{% endblock %}\n\nBut it doesn't work. We can't touch blocks in includes.\n\nIf i just put the content of the \"meta.html\" in the \"base.html\" template, it works as wanted. But i don't want to do that....\n\nAny idea on how to accomplish my wish ?\n\nThanks in advance", "group_id": 81, "id": 1439287}, {"user_id": 1736, "stars": [], "topic_id": 39875, "date_created": 1308589317.1516011, "message": "This sounds like a place to use a custom templatetag.", "group_id": 81, "id": 1440266}, {"user_id": 1736, "stars": [], "topic_id": 39875, "date_created": 1308590132.439851, "message": "The meta fields wouldn't be pulled in via include, they would be an inclusion tag, and you could pass in that fields you want to override as tag arguments", "group_id": 81, "id": 1440367}, {"user_id": 30572, "stars": [], "topic_id": 39875, "date_created": 1308589963.1644349, "message": "It can be an idea but i don't see how to implement this particular one !", "group_id": 81, "id": 1440340}, {"user_id": 30572, "stars": [], "topic_id": 39875, "date_created": 1308590294.170522, "message": "I have another idea : in my \"base.html\" i put my {% include \"meta.html\" %} in a block :\n\n{% block meta %}{% include \"meta.html\" %}{% endblock %}\n\nAnd in templates extending \"base.html\" where i need to change its content i can do\n\n{% block meta %}\n {% with og_title=\"My page\" %}\n\t{{ block.super }}\n {% endwith %}\n{% endblock %}\n\nAnd in my \"meta.html\" i can do\n\n<meta property=\"og:title\" content=\"{{ og_title|default:\"Foo bar !\" }}\" />\n", "group_id": 81, "id": 1440381}, {"user_id": 1736, "stars": [], "topic_id": 39875, "date_created": 1308590439.0846751, "message": "That would be functionally identical but much more complex", "group_id": 81, "id": 1440415}, {"user_id": 30572, "stars": [], "topic_id": 39875, "date_created": 1308590502.8499241, "message": "I'm not sure how to use inclusion tag with your method. I'll check this. Thanks !", "group_id": 81, "id": 1440430}]