How to use the mustache.mustache.render function in mustache

To help you get started, we’ve selected a few mustache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cockpit-project / cockpit / pkg / systemd / init.js View on Github external
return;
                if (current_text_filter && unit.Description.toLowerCase().indexOf(current_text_filter) == -1 &&
                                           unit.Id.indexOf(current_text_filter) == -1)
                    return;
                if (current_type_filter !== 0 && current_type_filter !== unit.AutomaticStartupIndex)
                    return;
                unit.shortId = unit.Id;
                // Remove ".service" from services as this is not necessary
                if (unit.Id.endsWith(".service"))
                    unit.shortId = unit.Id.substring(0, unit.Id.length - 8);
                units.push(unit);
            });

            var text = "";
            if (units.length > 0)
                text = mustache.render(units_template, {
                    table_head: header,
                    units: units
                });
            else
                text = mustache.render(empty_template);
            $("#services-list").html(text);
        }
github cockpit-project / cockpit / pkg / users / local.js View on Github external
var keys_html = mustache.render(this.keys_template, {
                    keys: keys,
                    empty: keys.length === 0 && state == "ready",
                    denied: state == "access-denied",
                    failed: state == "failed",
                });
                $('#account-authorized-keys-list').html(keys_html);
                $(".account-remove-key")
                        .on("click", $.proxy(this, "remove_key"));
                $('#account-authorized-keys').show();
            } else {
                $('#account-authorized-keys').hide();
            }

            if (this.account.uid !== 0) {
                var html = mustache.render(this.role_template,
                                           { roles: this.roles, changed: this.roles_changed });
                $('#account-change-roles-roles').html(html);
                $('#account-roles').parents('tr')
                        .show();
                $('#account-roles [data-toggle="tooltip"]')
                        .tooltip();
                $("#account-change-roles-roles :input")
                        .on("change", $.proxy(this, "change_role"));
            } else {
                $('#account-roles')
                        .parents('tr')
                        .hide();
            }
            $('#account .breadcrumb .active')
                    .text(title_name);
github cockpit-project / cockpit / pkg / systemd / overview-cards / configurationCard.jsx View on Github external
if (self.server_time.timesyncd_service.state == "running")
                model.service = "systemd-timesyncd.service";

            if (timesyncd_status) {
                var match = timesyncd_status.match(timesyncd_server_regex);
                if (match)
                    model.Server = match[1];
                else if (timesyncd_status != "Idle." && timesyncd_status !== "")
                    model.SubStatus = timesyncd_status;
            }

            var tooltip_html = mustache.render(self.ntp_status_tmpl, model);
            if (tooltip_html != $ntp_status.attr("data-original-title"))
                $ntp_status.attr("data-original-title", tooltip_html);

            var icon_html = mustache.render(self.ntp_status_icon_tmpl, model);
            self.setState({ ntp_status_icon: { __html: icon_html } });
        }
github cockpit-project / cockpit / pkg / docker / run.js View on Github external
function render(volume_internal, volume_internal_editable) {
            if (volume_internal === undefined)
                volume_internal = '';
            if (volume_internal_editable === undefined)
                volume_internal_editable = true;

            var row = $(mustache.render(template, {
                host_volume_label: _("to host path"),
                placeholder: _("none")
            }));
            row.children("button.fa-plus").on('click', add_row);
            if (volume_internal_editable) {
                row.children("button.pficon-close").on('click', remove_row);
            } else {
                row.children("button.pficon-close").attr('disabled', true);
            }

            var row_container_input = row.find('input[name="container"]');
            row_container_input.val(volume_internal);
            if (!volume_internal_editable)
                row_container_input.attr('disabled', true);

            var mount_mode_select = row.find("div .mount-mode");
github cockpit-project / cockpit / pkg / lib / journal.js View on Github external
function render_day_header(day) {
        return mustache.render(day_header_template, { day: day });
    }
github cockpit-project / cockpit / pkg / docker / util.js View on Github external
    return strings.map(function (str) { return mustache.render("{{.}}", str) }).join('<br>');
};
github cockpit-project / cockpit / pkg / systemd / init.js View on Github external
function display_repeat() {
        $("#repeat-time").html(mustache.render(timer_unit.repeat.render, { repeat: repeat_array }));
        if (timer_unit.repeat.index === 525600) {
            var nowDate = new Date(clock_realtime_now);
            var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0);
            for (var i = 0; i &lt; repeat_array.length; i++) {
                $("[data-index='" + i + "'][data-content='datepicker']").datepicker({
                    autoclose: true,
                    todayHighlight: true,
                    format: 'yyyy-mm-dd',
                    orientation:"top auto",
                    container:'#timer-dialog',
                    startDate: today
                });
            }
        }
    }
github cockpit-project / cockpit / pkg / systemd / overview-cards / configurationCard.jsx View on Github external
if (!keys[title])
                                keys[title] = [];
                            keys[title].push(fp);
                        }
                    }

                    arr = Object.keys(keys);
                    arr.sort();
                    arr = arr.map(function(k) {
                        return { title: k, fps: keys[k] };
                    });

                    self.ssh_host_keys_tmpl = $("#ssh-host-keys-tmpl").html();
                    mustache.parse(self.ssh_host_keys_tmpl);

                    tmp = mustache.render(self.ssh_host_keys_tmpl, { keys: arr });
                    content.html(tmp);
                    spinner.toggle(false);
                    error.toggle(false);
                    content.prop("hidden", false);
                })
                .fail(function(ex) {
github cockpit-project / cockpit / pkg / users / local.js View on Github external
else if (!this.lastLogin)
                $('#account-last-login').text(_("Never"));
            else
                $('#account-last-login').text(this.lastLogin.toLocaleString());

            if (typeof this.locked != 'undefined') {
                $('#account-locked').prop('checked', this.locked);
                $('#account-locked').prop('disabled', false);
            } else {
                $('#account-locked').prop('disabled', true);
            }

            if (this.authorized_keys) {
                var keys = this.authorized_keys.keys;
                var state = this.authorized_keys.state;
                var keys_html = mustache.render(this.keys_template, {
                    keys: keys,
                    empty: keys.length === 0 && state == "ready",
                    denied: state == "access-denied",
                    failed: state == "failed",
                });
                $('#account-authorized-keys-list').html(keys_html);
                $(".account-remove-key")
                        .on("click", $.proxy(this, "remove_key"));
                $('#account-authorized-keys').show();
            } else {
                $('#account-authorized-keys').hide();
            }

            if (this.account.uid !== 0) {
                var html = mustache.render(this.role_template,
                                           { roles: this.roles, changed: this.roles_changed });