Skip to content
Permalink
Browse files
fix getnikola/nikola-site#15 -- document apply_to_(text|binary)_file
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 16, 2015
1 parent 0eeb940 commit 090186182c2ca0394eb0d8987d58bba6179a1684
Showing with 6 additions and 3 deletions.
  1. +6 −3 docs/manual.txt
@@ -1327,16 +1327,19 @@ The currently available filters are:
def yui_compressor(infile):
return runinplace(r'yui-compressor --nomunge %1 -o %2', infile)

You can turn any function into a filter using ``apply_to_file``.
You can turn any function into a filter using ``apply_to_text_file`` (for
text files to be read in UTF-8) and ``apply_to_binary_file`` (for files to
be read in binary mode).

As a silly example, this would make everything uppercase and totally break
your website:

.. code-block:: python

import string
from nikola.filters import apply_to_file
from nikola.filters import apply_to_text_file
FILTERS = {
".html": [apply_to_file(string.upper)]
".html": [apply_to_text_file(string.upper)]
}

minify_lines

0 comments on commit 0901861

Please sign in to comment.