Skip to content

Commit

Permalink
[docs] improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
phproberto committed Nov 17, 2017
1 parent 5d56bbd commit 94facac
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 15 deletions.
10 changes: 5 additions & 5 deletions docs/functions/jhtml.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ This function is a proxy of `HTMLHelper::_($key)`. It allows to access HTML draw
### Examples <a id="examples"></a>

```twig
{#
Render a form token. It will render something like:
<input type="hidden" name="19fa6812708e295180f8d5e08963cd5b" value="1" />
#}
{% raw %}{{ jhtml('form.token') }}{% endraw %}
{% raw %}
{# Render a form token. It will render something like:
<input type="hidden" name="19fa6812708e295180f8d5e08963cd5b" value="1" />#}
{{ jhtml('form.token') }}
{% endraw %}
```
4 changes: 3 additions & 1 deletion docs/functions/jlang.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This function is a proxy of `Language::getInstance()`. It allows to access HTML
### Examples <a id="examples"></a>

```twig
{% raw %}
{# Show the spanish language name #}
{% raw %}{{ jlang('es-ES').getName() }}{% endraw %}
{{ jlang('es-ES').getName() }}
{% endraw %}
```
2 changes: 1 addition & 1 deletion docs/functions/jlayout.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Create an instance of `\Joomla\CMS\Layout\FileLayout` to use it inside a twig la
### Examples <a id="examples"></a>

```twig
{# Create a layout instance of `joomla.system.message` to render some dynamically generated messages #}
{% raw %}
{# Create a layout instance of `joomla.system.message` to render some dynamically generated messages #}
{% set data = {
'msgList' : {
'error' : [
Expand Down
4 changes: 3 additions & 1 deletion docs/functions/jlayout_debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Fast debug of JLayout files rendering inside a twig layouts. Proxy of `\Joomla\C
### Examples <a id="examples"></a>

```twig
{% raw %}
{# Debug the joomla.html.treeprefix layout with ['level' => 10] as data #}
{% raw %}{{ jlayout_debug('joomla.html.treeprefix', {'level' : 10}) }}{% endraw %}
{{ jlayout_debug('joomla.html.treeprefix', {'level' : 10}) }}
{% endraw %}
```
4 changes: 3 additions & 1 deletion docs/functions/jlayout_render.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Fast rendering of JLayout files inside a twig layouts. Proxy of `\Joomla\CMS\Lay
### Examples <a id="examples"></a>

```twig
{% raw %}
{# Render the joomla.html.treeprefix layout with ['level' => 10] as data #}
{% raw %}{{ jlayout_render('joomla.html.treeprefix', {'level' : 10}) }}{% endraw %}
{{ jlayout_render('joomla.html.treeprefix', {'level' : 10}) }}
{% endraw %}
```
6 changes: 4 additions & 2 deletions docs/functions/jposition.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ It allows to render a module position inside a twig layout.
### Examples <a id="examples"></a>

```twig
{# Render the content of the template position-7 #}
{% raw %}{{ jposition('position-8') }}{% endraw %}
{% raw %}
{# Render the content of the template position-8 #}
{{ jposition('position-8') }}
{% endraw %}
```
10 changes: 8 additions & 2 deletions docs/functions/jprofiler.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## jprofiler($prefix = '')

This function is a proxy of `Joomla\CMS\Profiler\Profiler::getInstance()`. It allows to use a profiler to debug performance inside a twig layouts.
This function is a proxy of `Joomla\CMS\Profiler\Profiler::getInstance()`. It allows to use a profiler to debug performance inside twig layouts.
1. [Parameters](#parameters)
1. [Returns](#returns)
2. [Examples](#examples)
Expand All @@ -17,9 +17,15 @@ This function is a proxy of `Joomla\CMS\Profiler\Profiler::getInstance()`. It al

```twig
{% raw %}
{# Load a profiler and mark to points before and after doing something #}
{# Load a custom profiler with twig prefix. Best of jprofiler is that you can share profilers from PHP & twig to fully trace performance issues. #}
{% set profiler = jprofiler('twig') %}
{# echo memory & time consumed before doing something. If you want to hide in production while debugging an issue this you can use display: hidden in the container #}
<pre>{{ profiler.mark('before loading something') }}</pre>
{# Here what you want to debug #}
{# echo memory & time consumed after something.
<pre>{{ profiler.mark('after loading something') }}</pre>
{% endraw %}
```
3 changes: 2 additions & 1 deletion docs/functions/jtext.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ This function is a proxy of `Joomla\CMS\Language\Text::_()`. It allows to use tr

```twig
{% raw %}
{# Display the translation of the JENABLED language string #}
{# Display the translation of the JENABLED language string. It will display something like:
"Something is enabled" #}
Something is {{ jtext('JENABLED') }}
{% endraw %}
```
2 changes: 1 addition & 1 deletion docs/functions/juser.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This function is a proxy of `Joomla\CMS\Factory::getUser()`. It allows to retrie

```twig
{% raw %}
{# Retrieve active user not using any id #}
{# Retrieve active user not using any id. This is not usually required because you can already use `juser` global var #}
{% set activeUser = juser() %}
{# Retrieve the user with id: 668 #}
Expand Down

0 comments on commit 94facac

Please sign in to comment.