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

Closed
wants to merge 3 commits into
from

2 participants

@bmispelon bmispelon and 1 other commented on an outdated diff May 22, 2013
docs/howto/custom-template-tags.txt
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,
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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

@danielquinn
danielquinn added a line comment May 22, 2013

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
@bmispelon bmispelon and 1 other commented on an outdated diff May 22, 2013
docs/howto/custom-template-tags.txt
-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
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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

@danielquinn
danielquinn added a line comment May 22, 2013

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
@bmispelon bmispelon and 1 other commented on an outdated diff May 22, 2013
docs/howto/custom-template-tags.txt
-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:
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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

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

@danielquinn
danielquinn added a line comment May 22, 2013

Good catch. Fixt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bmispelon bmispelon commented on the diff May 22, 2013
docs/howto/custom-template-tags.txt
.. code-block:: python
- @register.tag(name="current_time")
- def do_current_time(parser, token):
+ @register.inclusion_tag('my_template.html')
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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
@bmispelon bmispelon commented on the diff May 22, 2013
docs/howto/custom-template-tags.txt
-.. _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
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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
@bmispelon bmispelon commented on the diff May 22, 2013
docs/howto/custom-template-tags.txt
-Inclusion tags
-~~~~~~~~~~~~~~
+Parsing until another block tag
@bmispelon
Django member
bmispelon added a line comment May 22, 2013

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
@timgraham
Django member

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

@timgraham timgraham closed this May 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment