Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed #20435 Rearranged some paragraphs to situate the simple stuff first #1125

Closed
wants to merge 3 commits into from

4 participants

Daniel Quinn Tim Graham Baptiste Mispelon jsibbiso
docs/howto/custom-template-tags.txt
((5 lines not shown))
Writing custom template tags
----------------------------
-Tags are more complex than filters, because tags can do anything.
+Tags are more complex than filters, because tags can do anything. Thankfully,
Baptiste Mispelon Collaborator

Why the double-space after a period? It's not consistent with the rest of the documentation.

Habit of mine. I've fixed this now too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/howto/custom-template-tags.txt
((35 lines not shown))
-Writing the compilation function
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Many template tags take a number of arguments -- strings or template variables
+-- and return a string after doing some processing based solely on
+the input arguments and some external information. For example, the
+``current_time`` tag we wrote above is of this variety: we give it a format
Baptiste Mispelon Collaborator

The current_time tag is no longer defined above this so this needs to be re-written.

I've fixed this now by rewriting both this reference and the original description of current_time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/howto/custom-template-tags.txt
((51 lines not shown))
-For example, let's write a template tag, ``{% current_time %}``, that displays
-the current date/time, formatted according to a parameter given in the tag, in
-:func:`~time.strftime` syntax. It's a good idea to decide the tag syntax before
-anything else. In our case, let's say the tag should be used like this:
+Our earlier ``current_time`` function could thus be written like this:
Baptiste Mispelon Collaborator

The "our earlier" bit should probably be changed too.

Maybe something like "Our current_time function could thus be written like this"?

Good catch. Fixt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Baptiste Mispelon bmispelon commented on the diff
docs/howto/custom-template-tags.txt
((438 lines not shown))
.. code-block:: python
- @register.tag(name="current_time")
- def do_current_time(parser, token):
+ @register.inclusion_tag('my_template.html')
Baptiste Mispelon Collaborator

This whole section should be moved back to the bottom of the page since we haven't introduced how to write complex tags yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Baptiste Mispelon bmispelon commented on the diff
docs/howto/custom-template-tags.txt
((591 lines not shown))
-.. _howto-custom-template-tags-simple-tags:
+The difference here is that ``do_current_time()`` grabs the format string and
+the variable name, passing both to ``CurrentTimeNode3``.
+
+Finally, if you only need to have a simple syntax for your custom
Baptiste Mispelon Collaborator

This paragraph can probably be deleted since we're now introducing the simple version first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Baptiste Mispelon bmispelon commented on the diff
docs/howto/custom-template-tags.txt
((8 lines not shown))
-Inclusion tags
-~~~~~~~~~~~~~~
+Parsing until another block tag
Baptiste Mispelon Collaborator

This section should also be moved back to the bottom since it's making use of the complex way of writing custom tags, which hasn't been introduced yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Tim Graham
Owner

Could you rebase this and re-open or open a new pull request? thanks!

Tim Graham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.