From 0e6929d1cc541692935a3619ec41ea040665394e Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Fri, 2 Aug 2013 12:05:22 +0000 Subject: [PATCH] Add some advice about template parameters in PLUGINS. --- NEWS | 4 ++++ PLUGINS | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 29c9c5e..673063e 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,10 @@ Be consistent about catching AttributeError when looking for attributes that were added to Rawdog during the 2.x series (spotted by Jakub Wilk). +Add some advice in PLUGINS about escaping template parameters. Willem +reported that the enclosure plugin didn't do this, and having had a look +at the others it seems to be a common problem. + - rawdog 2.17 Add a one-paragraph description of rawdog to the README file, for use by diff --git a/PLUGINS b/PLUGINS index 65f18ed..57fc3ec 100644 --- a/PLUGINS +++ b/PLUGINS @@ -169,9 +169,20 @@ Called after all items are written. * bits: a dictionary of template parameters -Called before expanding the main template. This hook can be used to add +Called before expanding the page template. This hook can be used to add extra template parameters. +Note that template parameters should be valid HTML, with entities +escaped, even if they're URLs or similar. You can use rawdog's +`rawdoglib.rawdog.string_to_html` function to do this for you: + + the_thing = "This can contain arbitary text & stuff" + bits["thing"] = string_to_html(the_thing, config) + +It's also good idea for template parameter names to be valid Python +identifiers, so that plugins that replace the template system with +something smarter can make them into local variables. + ### output_item_bits(rawdog, config, feed, article, bits) * feed: the Feed containing this article @@ -181,6 +192,9 @@ extra template parameters. Called before expanding the item template for an article. This hook can be used to add extra template parameters. +(See the documentation for `output_bits` for some advice on adding +template parameters.) + ### pre_update_feed(rawdog, config, feed) * feed: the Feed about to be updated -- 2.35.1