@@ -642,16 +642,22 @@ handler function, ``site`` and ``data`` will be added to the keyword arguments.
642
642
643
643
Example:
644
644
645
- The following shortcode::
645
+ The following shortcode:
646
+
647
+ .. code:: text
646
648
647
649
{{% raw %}}{{% foo bar="baz" spam %}}{{% /raw %}}
648
650
649
651
With a template in ``shortcodes/foo.tmpl`` with this content (using Jinja2
650
- syntax in this example)::
652
+ syntax in this example)
653
+
654
+ .. code:: jinja
651
655
652
656
<div class="{{ _args[0] if _args else 'ham' }}">{{ bar }}</div>
653
657
654
- Will result in this output::
658
+ Will result in this output
659
+
660
+ .. code:: html
655
661
656
662
<div class="spam">baz</div>
657
663
@@ -661,8 +667,8 @@ State and Cache
661
667
662
668
Sometimes your plugins will need to cache things to speed up further actions. Here are the conventions for that:
663
669
664
- * If it's a file, put it somewhere in ``` self.site.config['CACHE_FOLDER']``` (defaults to ``` cache/` ``.
665
- * If it's a value, use ``` self.site.cache.set(key, value)``` to set it and ``` self.site.cache.get(key)` `` to get it.
670
+ * If it's a file, put it somewhere in ``self.site.config['CACHE_FOLDER']`` (defaults to ``cache/``.
671
+ * If it's a value, use ``self.site.cache.set(key, value)`` to set it and ``self.site.cache.get(key)`` to get it.
666
672
The key should be a string, the value should be json-encodable (so, be careful with datetime objects)
667
673
668
674
The values and files you store there can **and will** be deleted sometimes by the user. They should always be
@@ -672,11 +678,11 @@ On the other hand, sometimes you want to save something that is **not** a throwa
672
678
change the output, so the user should not delete them. We call that **state**. To save state:
673
679
674
680
* If it's a file, put it somewhere in the working directory. Try not to do that please.
675
- * If it's a value, use ``` self.site.state.set(key, value)``` to set it and ``` self.state.cache.get(key)` `` to get it.
681
+ * If it's a value, use ``self.site.state.set(key, value)`` to set it and ``self.state.cache.get(key)`` to get it.
676
682
The key should be a string, the value should be json-encodable (so, be careful with datetime objects)
677
683
678
- The ``` cache``` and ``` state` `` objects are rather simplistic, and that's intentional. They have no default values: if
679
- the key is not there, you will get ``` None` `` and like it. They are meant to be both threadsafe, but hey, who can
684
+ The ``cache`` and ``state`` objects are rather simplistic, and that's intentional. They have no default values: if
685
+ the key is not there, you will get ``None`` and like it. They are meant to be both threadsafe, but hey, who can
680
686
guarantee that sort of thing?
681
687
682
688
There are no sections, and no access protection, so let's not use it to store passwords and such. Use responsibly.
0 commit comments