Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
---
2
layout: docs
3
title: "Moodle templates"
4
date: 2020-01-14T13:38:37+01:00
5
group: moodle-components
6
draft: false
7
menu: "main"
8
---
9
 
10
## Moodle templates
11
 
12
[Moodle templates](https://moodledev.io/docs/guides/templates) are use to write HTML and Javascript using mustache files.
13
 
14
If you are creating your own pages in the UI Component library you can load core templates using this (shortcode) syntax:
15
 
16
```
17
{{</* mustache template="core/notification_error" */>}}
18
{{</* /mustache */>}}
19
```
20
 
21
This is the result of adding the core/notification template on this page:
22
 
23
{{< mustache template="core/notification_error" >}}
24
{{< /mustache >}}
25
 
26
This allows you to document any mustache template in the component library.
27
 
28
## Moodle templates with custom data
29
 
30
Not all templates found in Moodle core are will documented with example JSON formatted data (see the variables tab for the notification_error). To use custom Json data please use this (shortcode) syntax:
31
 
32
```
33
{{</* mustache template="core/notification_error" */>}}
34
{
35
    "message": "Your pants are awesome!",
36
    "closebutton": 1,
37
    "announce": 1,
38
    "extraclasses": "foo bar"
39
}
40
{{</* /mustache */>}}
41
```
42
 
43
 
44
This is the result of adding the core/notification template on this page:
45
 
46
{{< mustache template="core/notification_error" >}}
47
{
48
    "message": "Your pants are awesome!",
49
    "closebutton": 1,
50
    "announce": 1,
51
    "extraclasses": "foo bar"
52
}
53
{{< /mustache >}}