How to use the handlebars.SafeString function in handlebars

To help you get started, we’ve selected a few handlebars 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 nodejs / iojs.org / gulp / util / content.js View on Github external
// function(key, env)
    if (arguments.length === 2) {
      key = arguments[0];
      env = arguments[1];
    }
    // function(scope, key, env)
    if (arguments.length === 3) {
      key = arguments[0] + '.' + arguments[1];
      env = arguments[2];
    }

    var data = env.data.root;
    var result = traverse(data.i18n, key);

    return new Handlebars.SafeString(result);
  });
github NewsJelly / jelly-chart / demo / demo.js View on Github external
let containers;
      if (l.containers && l.containers > 1) {
        let i = 0;
        while( i< l.containers) {
          containers.push('jelly-container-' + i);
        }
      } else {
        containers = ['jelly-container'];
      }
      const code = await readFile(path.resolve(__dirname, srcDir, categoryPath, l.path, 'index.js'));
      const desc = await readFile(path.resolve(__dirname, srcDir, categoryPath, l.path, 'index.md'));
      const context = {
        dev: dev,
        path: l.path, 
        title: l.title, 
        desc: new handlebars.SafeString(marked(desc.toString())),
        code: new handlebars.SafeString(code.toString()),
        group: group,
        containers: containers, 
        daum: l.daum
      };
      if (lastL) lastL.selected = false;
      l.selected = true;
      lastL = l;
      await writeFile(path.resolve(__dirname, distDir, l.path + '.html'), template(context))
    }
  } catch (e) {
    console.error(e);
  }
}
github Financial-Times / polyfill-service / packages / polyfill-service / service / routes / docs.js View on Github external
sectionHighlight: (section, pageName) => {
		return (section === pageName) ? new Handlebars.SafeString(' aria-selected="true"') : '';
	},
	dispBytes: bytes => {
github rr- / szurubooru / client / js / util / handlebars-helpers.js View on Github external
handlebars.registerHelper('thumbnail', function(url) {
    return new handlebars.SafeString(
        views.makeNonVoidElement('span', {
            class: 'thumbnail',
            style: 'background-image: url(\'{0}\')'.format(url)
        }, views.makeVoidElement('img', {alt: 'thumbnail', src: url})));
});
github 1cgonza / dddrawings / tasks / hbs-helpers / pageTitle.js View on Github external
export default title => {
  let pageTitle = metadata.siteTitle;

  if (title && title.length > 0 && title !== 'Home') {
    pageTitle = title + ' :: ' + metadata.siteTitle;
  }

  return new SafeString(pageTitle);
};
github Radarr / Radarr / src / UI / Handlebars / Helpers / Movie.js View on Github external
Handlebars.registerHelper('GetBannerStatus', function() {
  var monitored = this.monitored;
  var status = this.status;
  //var inCinemas = this.inCinemas;
  //var date = new Date(inCinemas);
  //var timeSince = new Date().getTime() - date.getTime();
  //var numOfMonths = timeSince / 1000 / 60 / 60 / 24 / 30;


  if (status === "inCinemas") {
    return new Handlebars.SafeString('<div class="cinemas-banner"><i title="" class="icon-radarr-movie-cinemas grid-icon"></i>&nbsp;In Cinemas</div>');
  }

  if (status === "announced") {
    return new Handlebars.SafeString('<div class="announced-banner"><i title="" class="icon-radarr-movie-announced grid-icon"></i>&nbsp;Announced</div>');
  }
  else if (!monitored) {
      return new Handlebars.SafeString('<div class="announced-banner"><i title="" class="icon-radarr-series-unmonitored grid-icon"></i>&nbsp;Not Monitored</div>');
  }
});
github Crossbow-js / crossbow-sites / lib / plugins / handlebars / data.js View on Github external
required: ["src", "as"],
            error:    "You must provide both `src` & `as` parameters to the data helper",
            type:     "data:params"
        });

        if (!params && inlineErrors) {
            return new Handlebars.SafeString(errors["data:as"]());
        }

        var fileout = fileHelper.retrieveFile({
            options: options,
            params: params
        });

        if (fileout.inlineError && inlineErrors) {
            return new Handlebars.SafeString(fileout.inlineError);
        }

        var data = fileHelper.retrieveFile({options: options, params: params}).data;

        var sandbox = require("lodash/lang/cloneDeep")(compiler.frozen);

        sandbox[params.as] = data;

        /**
         * Attempt to get a file from cache, or wherever
         */
        return options.fn(sandbox);
    };
};
github zce / x-pages / lib / hbs.js View on Github external
const renderLayout = (layout, body) => {
    const content = fm(fs.readFileSync(path.join(config.layouts, layout + '.html'), 'utf8'))

    Object.assign(page, content.attributes)

    const template = hbs.compile(content.body)

    page.body = new hbs.SafeString(body)

    let result = template(page, { data: { site } })

    if (content.attributes.layout) {
      result = renderLayout(content.attributes.layout, result)
    }

    return result
  }
github cliss / camel / camel.js View on Github external
Handlebars.registerHelper('formatDate', function (date) {
		return new Handlebars.SafeString(new Date(date).format('{Weekday}<br>{d}<br>{Month}<br>{yyyy}'));
	});
	Handlebars.registerHelper('dateLink', function (date) {
github jquery / download.jqueryui.com / themeroller.js View on Github external
Handlebars.registerHelper( "selected", function( param, value ) {
	return new Handlebars.SafeString( param === value ? "selected=\"selected\"" : "" );
});