Commit Graph

49 Commits

Author SHA1 Message Date
Tim Schroeder
f8f04b773d MDL-66542 lib: Fix quote escaping in JS quote helper 2019-09-30 10:09:07 +02:00
Jake Dallimore
2796356278 Merge branch 'MDL-66367_master' of git://github.com/markn86/moodle 2019-09-05 09:26:28 +08:00
Mark Nelson
af8a70756f MDL-66367 core: don't cache templates if templaterev is invalid 2019-09-04 12:54:02 +02:00
Mark Nelson
9e5edc7f68 MDL-66367 core: use templaterev as the cache key when getting templates 2019-09-04 12:54:02 +02:00
Ryan Wyllie
3fb0cbd4bb MDL-62284 javascript: prevent nested JS mustache handler calls
Prevent the JS mustache helper from being executed from within
the render call of another mustache helper because it can allow
users to inject JS into the page.
2019-09-04 11:22:51 +08:00
Andrew Nicols
0261d1effa MDL-50346 core: Allow sub-directories in template names 2019-08-07 11:44:49 +08:00
Ryan Wyllie
195ea4480b MDL-62497 javascript: build AMD modules with new transpiler 2019-07-19 14:12:49 +08:00
Mark Nelson
3f7360f07d MDL-65794 core: use themerev as the cache key when getting templates 2019-07-16 14:23:34 +08:00
Kristian Ringer
6c97045e5e MDL-65183 block_timeline: escape newline characters 2019-06-07 09:37:34 +10:00
Simey Lameze
545e2abb91 MDL-63244 core: make mustache retrieve language 2019-03-19 15:03:51 +08:00
Ryan Wyllie
c77ba4890a MDL-64348 javascript: change template loading to a buffer
Changed the template loading to buffer the requests for templates
so that they can be sent in batches to the server to save large
volumes of network requests.
2019-01-07 09:03:06 +08:00
Ryan Wyllie
2b92891a88 MDL-64348 javascript: change template loading to also load dependencies
Changed the getTemplate function in templates.js to use the
core_output_load_template_with_dependencies function to load the
requested template and all of the dependencies required to render it.

The dependencies are added to the relevant caches so that when the
template is rendered they aren't re-requested from the server.
2019-01-07 09:03:06 +08:00
Andrew Nicols
23e347bb32 MDL-64181 core: Ensure that self is included in parentage 2018-11-27 14:42:40 +08:00
Damyon Wiese
a2cb00b655 MDL-64181 javascript: Recursive template fix
This change prevents template rendering from waiting for itself, but does
allow it to wait for another async call to render.
2018-11-27 08:44:36 +08:00
Andrew Nicols
eb514bb3e5 MDL-63714 javascript: Add new core/pending module 2018-10-24 12:49:09 +08:00
Andrew Nicols
4b7ad8845c MDL-63714 core: Wrap doRender in pendingjs 2018-10-24 08:12:10 +08:00
Andrew Nicols
61e0f58ca3 MDL-63667 amd: Check for parent template recursion 2018-10-18 12:04:19 +08:00
Damyon Wiese
b51c5b929f MDL-63667 output: Fix for recursive templates
A template can include itself - e.g. by looping over the context children and rendering a tree.

Ensure this promise still resolves.

Example: admin/tool/lp/templates/competencies_tree.mustache.
2018-10-18 10:48:01 +08:00
Ryan Wyllie
0015f5b8f1 MDL-63667 javascript: fix failed to pre-fetch the template error 2018-10-17 13:49:25 +08:00
Dan Poltawski
50c277a5d8 MDL-57139 js: built 2017-06-01 14:54:40 +01:00
David Mudrák
74e238f4b7 MDL-58760 templates: Make {{#pix}} helper work with escaped icon key
There is a difference between how our PHP mustache engine and JS
mustache engine escaping works. If the icon key is not hard-coded in the
template but defined as a context variable, the JS mustache engine
escapes the forward slashes.
2017-04-28 23:04:04 +02:00
Ryan Wyllie
e03d5d4790 MDL-57445 core: allow context variables in pix helper
Allow the user of context variables in the id and component section of
the pix helper.

Part of MDL-55611 epic.
2017-04-03 11:35:37 +08:00
Dan Poltawski
dca0ea03b1 Merge branch 'MDL-58317-master' of git://github.com/damyon/moodle 2017-03-21 08:03:42 +00:00
Damyon Wiese
f4e623b3e7 MDL-58317 templates: Fix async template render
There is an edge case where we do not wait for all promises before
rendering a template. This can generate "failed to pre-fetch the template" JS errors.
2017-03-20 13:29:09 +08:00
Damyon Wiese
e330b1c214 MDL-40759 icons: Refactor to allow theme icon systems 2017-03-17 15:52:18 +08:00
Damyon Wiese
95b06c13c6 MDL-40759 icons: Refactor icon system to be extensible. 2017-03-17 15:51:29 +08:00
Andrew Nicols
e2310e4361 Merge branch 'MDL-57975-master' of git://github.com/ryanwyllie/moodle 2017-03-10 18:04:42 +00:00
Ryan Wyllie
0e5b3e282f MDL-57975 javascript: add userdate mustache js helper
Part of MDL-55611
2017-03-08 03:33:24 +00:00
Ryan Wyllie
75378ded5f MDL-57972 mustache: add shortentext template helper
Part of MDL-55611
2017-03-07 06:33:56 +00:00
Damyon Wiese
f3cd5c5b7b MDL-57009 javascript: Always use when.apply
Or it does not really wait for the promises.
2017-02-07 15:03:43 +08:00
Damyon Wiese
b302369d17 MDL-57009 javascript: cibot nagging 2017-02-02 15:54:19 +08:00
Damyon Wiese
39bf2a985b MDL-57009 javascript: Dont rely on async ajax
Recursively pre-scan mustache templates to extract the list of blocks and partials. Then
we can pre-fetch them all and don't have to rely on jquery async ajax (which is deprecated).

This is part of a refactoring of the promises code in the templates module to prevent duplicate requests.
2017-02-02 15:54:19 +08:00
Damyon Wiese
f20a336b43 MDL-57009 js: Do not fetch the same template twice
Also clean up promises use of done vs then.
2017-02-02 15:54:19 +08:00
Andrew Nicols
ab00bf59a5 Merge branch 'MDL-56341-master' of git://github.com/damyon/moodle 2016-10-24 10:11:20 +08:00
Frédéric Massart
a89cf23744 MDL-56341 mustache: JS engines handles strings wrapped in quote
Prior to the patch the strings wrapped as the following one
where not found and replaced when rendering the template via Javascript

{{#quote}}{{#str}}string,component{{/str}}{{/quote}}
2016-10-20 12:13:42 +08:00
Mark Nelson
d4b2c195e1 MDL-54682 core: build amd modules 2016-10-11 14:39:24 +08:00
Mark Nelson
8354d12d39 MDL-55771 core: added title attribute when using JS to render {{pix}} 2016-08-30 14:49:44 +08:00
Damyon Wiese
8d00afb12c MDL-54915 templates: Fix async rendering of js blocks
Mustache JS helper can overwrite JS blocks when using nested templates.

Each call to render should have it's own scope.
2016-07-19 12:55:50 +08:00
Dan Poltawski
7f70d548fe MDL-54939 amd: build modified files 2016-06-17 09:03:18 +01:00
Frederic Massart
29879f8f4c MDL-53667 templates: Improve JS string handling in templates
The native String.replace method in extremely slow when we are
dealing with a large string and large quantity of strings to replace.
This new solution walks through the string looking for placeholders
to replace.
2016-04-18 17:14:32 +08:00
Damyon Wiese
1fca8a7bdd MDL-53056 javascript: Improve the fragments API
Instead of injecting the HTML + JS directly - return a promise that is resolve with
the HTML and JS. This gives the caller control over how and when to inject the nodes
in the DOM. Also modify templates.replaceNode functions to cleanup YUI events mess.
Also pass the context to the callback so it can be verified.
Also pass the arguments to the callback as a named array - not a flat argument list.
Also - only load external scripts if they are not already loaded.
2016-03-30 11:48:38 +08:00
Eloy Lafuente (stronk7)
df190d18a1 MDL-52136 mod_forum: fix some out-of-sync stuff
Thanks CIs!
2016-03-02 05:42:29 +01:00
Dan Poltawski
f992dcf6e8 MDL-52204 js: fix 'used before defined' errors
Newer versions of jshint detect this coding error, we fix it
by simply reordering the definition of methods.
2015-12-04 11:43:10 +00:00
Damyon Wiese
28de777199 MDL-51222 Javascript: Trigger events for filters on DOM insertion
When nodes are added to the dom, they may need to be re-processed by a JS based
filter. To do this we need to trigger the legacy YUI event filter-content-updated.

To make this easier I added some wrappers to template that will insert the node, run any
JS and trigger the event.

I also changed existing yui code to call the amd function to trigger the event. This way
all jquery and yui listeners will always be notified.
2015-09-22 15:40:51 +08:00
Damyon Wiese
ba224fb42c MDL-50783 Ajax: Configure how to call a webservice through db/service.php
Now the db/service.php array can contain these extra keys to provide information
on how a webservice may be called:

    'ajax' => true (Default is false)

Replaces the xx_is_allowed_from_ajax callback.

    'loginrequired' => false (Default is true)

Means that this webservice can be called through lib/ajax/service-nosession.php
which sets NO_MOODLE_COOKIES to true (faster). This is only safe for webservices returning
static public data (e.g. get_string).
2015-09-14 15:10:21 +08:00
Damyon Wiese
e0d08bfa5d MDL-51116 Mustache: Caching issue exists with mustache templates
The first ajax load fetches the template and puts it in localstorage + a js var

The second load gets it from local storage, but does not put it in the js var.

The pix_icon helper expects it to be in the js var always.
2015-08-24 10:50:40 +08:00
Jetha Chan
e37d53dac1 MDL-50520 templates: fix helpers not firing inside pix helper 2015-06-09 15:23:04 +08:00
Damyon Wiese
4b9e532633 MDL-49604 Javascript: Add a localstorage cache for strings and templates 2015-04-08 12:31:48 +08:00
Damyon Wiese
9bdcf57951 MDL-49152 output: Templates for renderers (JS and PHP)
Mustache support for rendering templates from either php or js.
2015-03-14 22:48:40 +08:00