How to use the mustache.mustache.parse 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
clock_realtime_now = moment.unix(parseInt(time));
                });
    }
    update_time();
    var timedate_client = cockpit.dbus('org.freedesktop.timedate1');
    timedate_client.subscribe({
        interface: "org.freedesktop.DBus.Properties",
        member: "PropertiesChanged"
    }, update_time);
    var timer_unit = { };
    var repeat_array = [];
    var error = false;
    var repeat_hourly_template = $("#repeat-hourly-tmpl").html();
    mustache.parse(repeat_hourly_template);
    var repeat_daily_template = $("#repeat-daily-tmpl").html();
    mustache.parse(repeat_daily_template);
    var repeat_weekly_template = $("#repeat-weekly-tmpl").html();
    mustache.parse(repeat_weekly_template);
    var repeat_monthly_template = $("#repeat-monthly-tmpl").html();
    mustache.parse(repeat_monthly_template);
    var repeat_yearly_template = $("#repeat-yearly-tmpl").html();
    mustache.parse(repeat_yearly_template);
    /* Available Options for timer creation
     * Don't Repeat   : 0
     * Repeat Hourly  : 60     (60min)
     * Repeat Daily   : 1440   (60*24min)
     * Repeat Weekly  : 10080  (60*24*7min)
     * Repeat Monthly : 44640  (60*24*31min)
     * Repeat Yearly  : 525600 (60*24*365min)
     */
    var repeat_option = [
        { index: 0, render: "" },
github cockpit-project / cockpit / pkg / systemd / host.js View on Github external
self.server_time = new ServerTime();
        $(self.server_time).on("changed", function() {
            $('#system_information_systime_button').text(self.server_time.format(true));
        });

        self.server_time.client.subscribe({
            interface: "org.freedesktop.DBus.Properties",
            member: "PropertiesChanged"
        }, self.server_time.ntp_updated);

        self.ntp_status_tmpl = $("#ntp-status-tmpl").html();
        mustache.parse(this.ntp_status_tmpl);

        self.ntp_status_icon_tmpl = $("#ntp-status-icon-tmpl").html();
        mustache.parse(this.ntp_status_icon_tmpl);

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

        $("#system_information_ssh_keys").on("show.bs.modal", function() {
            self.host_keys_show();
        });

        $("#system_information_ssh_keys").on("hide.bs.modal", function() {
            self.host_keys_hide();
        });

        var $ntp_status = $('#system_information_systime_ntp_status');

        function update_ntp_status() {
            // flag for tests that timedated proxy got activated
github cockpit-project / cockpit / pkg / lib / journal.js View on Github external
function output_funcs_for_box(box) {
    /* Dereference any jQuery object here */
    if (box.jquery)
        box = box[0];

    mustache.parse(day_header_template);
    mustache.parse(line_template);
    mustache.parse(reboot_template);

    function render_line(ident, prio, message, count, time, entry) {
        var parts = {
            cursor: entry.__CURSOR,
            time: time,
            message: message,
            service: ident
        };
        if (count > 1)
            parts.count = count;
        if (ident === 'abrt-notification') {
            parts.problem = true;
            parts.service = entry.PROBLEM_BINARY;
        } else if (prio < 4)
            parts.warning = true;
github cockpit-project / cockpit / pkg / lib / journal.js View on Github external
function output_funcs_for_box(box) {
    /* Dereference any jQuery object here */
    if (box.jquery)
        box = box[0];

    mustache.parse(day_header_template);
    mustache.parse(line_template);
    mustache.parse(reboot_template);

    function render_line(ident, prio, message, count, time, entry) {
        var parts = {
            cursor: entry.__CURSOR,
            time: time,
            message: message,
            service: ident
        };
        if (count > 1)
            parts.count = count;
        if (ident === 'abrt-notification') {
            parts.problem = true;
            parts.service = entry.PROBLEM_BINARY;
        } else if (prio < 4)
            parts.warning = true;
        return mustache.render(line_template, parts);
github cockpit-project / cockpit / pkg / systemd / init.js View on Github external
interface: "org.freedesktop.DBus.Properties",
        member: "PropertiesChanged"
    }, update_time);
    var timer_unit = { };
    var repeat_array = [];
    var error = false;
    var repeat_hourly_template = $("#repeat-hourly-tmpl").html();
    mustache.parse(repeat_hourly_template);
    var repeat_daily_template = $("#repeat-daily-tmpl").html();
    mustache.parse(repeat_daily_template);
    var repeat_weekly_template = $("#repeat-weekly-tmpl").html();
    mustache.parse(repeat_weekly_template);
    var repeat_monthly_template = $("#repeat-monthly-tmpl").html();
    mustache.parse(repeat_monthly_template);
    var repeat_yearly_template = $("#repeat-yearly-tmpl").html();
    mustache.parse(repeat_yearly_template);
    /* Available Options for timer creation
     * Don't Repeat   : 0
     * Repeat Hourly  : 60     (60min)
     * Repeat Daily   : 1440   (60*24min)
     * Repeat Weekly  : 10080  (60*24*7min)
     * Repeat Monthly : 44640  (60*24*31min)
     * Repeat Yearly  : 525600 (60*24*365min)
     */
    var repeat_option = [
        { index: 0, render: "" },
        { index: 60, render: repeat_hourly_template },
        { index: 1440, render: repeat_daily_template },
        { index: 10080, render: repeat_weekly_template },
        { index: 44640, render: repeat_monthly_template },
        { index: 525600, render: repeat_yearly_template }
    ];
github cockpit-project / cockpit / pkg / systemd / init.js View on Github external
})
                .done(function(time) {
                    clock_realtime_now = moment.unix(parseInt(time));
                });
    }
    update_time();
    var timedate_client = cockpit.dbus('org.freedesktop.timedate1');
    timedate_client.subscribe({
        interface: "org.freedesktop.DBus.Properties",
        member: "PropertiesChanged"
    }, update_time);
    var timer_unit = { };
    var repeat_array = [];
    var error = false;
    var repeat_hourly_template = $("#repeat-hourly-tmpl").html();
    mustache.parse(repeat_hourly_template);
    var repeat_daily_template = $("#repeat-daily-tmpl").html();
    mustache.parse(repeat_daily_template);
    var repeat_weekly_template = $("#repeat-weekly-tmpl").html();
    mustache.parse(repeat_weekly_template);
    var repeat_monthly_template = $("#repeat-monthly-tmpl").html();
    mustache.parse(repeat_monthly_template);
    var repeat_yearly_template = $("#repeat-yearly-tmpl").html();
    mustache.parse(repeat_yearly_template);
    /* Available Options for timer creation
     * Don't Repeat   : 0
     * Repeat Hourly  : 60     (60min)
     * Repeat Daily   : 1440   (60*24min)
     * Repeat Weekly  : 10080  (60*24*7min)
     * Repeat Monthly : 44640  (60*24*31min)
     * Repeat Yearly  : 525600 (60*24*365min)
     */
github cockpit-project / cockpit / pkg / lib / machine-dialogs.js View on Github external
function translate_and_init(tmpl) {
    var tmp = $("<div>").append(tmpl);
    tmp.find("[translate=\"yes\"]").each(function(i, e) {
        var old = e.outerHTML;
        var translated = cockpit.gettext(e.getAttribute("context"), $(e).text());
        $(e).removeAttr("translate")
                .text(translated);
        tmpl = tmpl.replace(old, e.outerHTML);
    });
    mustache.parse(tmpl);
    return tmpl;
}
</div>
github cockpit-project / cockpit / pkg / systemd / init.js View on Github external
else {
                if (timer_unit.NextElapseUSecMonotonic + system_boot_time &lt; timer_unit.NextElapseUSecRealtime)
                    next_run_time = timer_unit.NextElapseUSecMonotonic + system_boot_time;
                else
                    next_run_time = timer_unit.NextElapseUSecRealtime;
            }
            unit.NextRunTime = moment(next_run_time / 1000).calendar();
            if (timer_unit.NextElapseUSecMonotonic &lt;= 0 &amp;&amp; timer_unit.NextElapseUSecRealtime &lt;= 0)
                unit.NextRunTime = _("unknown");
        }

        var units_template = $("#services-units-tmpl").html();
        mustache.parse(units_template);

        var empty_template = $("#service-empty-tmpl").html();
        mustache.parse(empty_template);

        function render_now() {
            $("#loading-fallback").hide();
            var current_text_filter = $('#services-text-filter').val()
                    .toLowerCase();
            var current_type_filter = parseInt($('#services-dropdown').val());

            function cmp_units(a, b) {
                const unit_a = units_by_path[a];
                const unit_b = units_by_path[b];
                const failed_a = unit_a.ActiveState == "failed" ? 1 : 0;
                const failed_b = unit_b.ActiveState == "failed" ? 1 : 0;

                if (failed_a != failed_b)
                    return failed_b - failed_a;
                else
github cockpit-project / cockpit / pkg / systemd / overview-cards / configurationCard.jsx View on Github external
title = m[1];
                            }
                            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 / docker / containers.js View on Github external
function init_curtain(client, navigate) {
    curtain_tmpl = $("#curtain-tmpl").html();
    mustache.parse(curtain_tmpl);

    $(client).on('failure', function (event, error) {
        show_curtain(error);
    });

    $('#curtain').on('click', '[data-action=docker-start]', function () {
        show_curtain(null);
        docker_service.start()
                .done(function () {
                    client.close();
                    client.connect().done(navigate);
                })
                .fail(function (error) {
                    show_curtain(cockpit.format(_("Failed to start Docker: $0"), error));
                });
    });