gilbitron/Pico — pull request #15 by ghuger (2013-02-23 23:22:05+00:00)
Title: Adding support for a {{ snippet }} tag

In response to:

This commit would add support for a new tag, {{ snippet }}, which is available in content files (.txt files)

Example:

{{ snippet foo }} would replaced by the contents of CONTENT_DIR/snippets/foo.txt

If foo.txt does not exist in the snippets directory, the tag is replaced with an empty string.

Notes:

- this code "takes over" the snippets folder within the content directory. It might be nice instead to make a SNIPPET_DIR constant or a config option
- matches {{ snippet foo-bar }} but not {{snippet foo-bar}}
- does not work in layouts, only in content files
- runs before the markdown parser
- does not sanitize the snippet name. this name is then passed to file_get_contents. (assuming templates can be trusted.)

I hope this is useful! I've not used GitHub before, so I hope I've done this correctly. Thanks so much for the great framework!

Cheers
George