How to use the handlebars/runtime.registerHelper 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 rubykit / kit / libraries / kit-doc / assets / src / js / html.js View on Github external
$(() => {
  // Set up Handlebars.js
  Handlebars.registerHelper('isArray', isArray)
  Handlebars.registerHelper('isLocal', isLocal)
  Handlebars.registerHelper('isNonEmptyArray', isNonEmptyArray)
  Handlebars.registerHelper('groupChanged', groupChanged)
  Handlebars.registerHelper('nestingChanged', nestingChanged)
  Handlebars.registerHelper('showSummary', showSummary)

  // Set up Highlight.js
  hljs.configure({
    tabReplace: '    ', // 4 spaces
    languages: [] // disable auto-detect
  })
  hljs.registerLanguage('bash', bash)
  hljs.registerLanguage('css', css)
  hljs.registerLanguage('diff', diff)
  hljs.registerLanguage('http', http)
  hljs.registerLanguage('javascript', javascript)
  hljs.registerLanguage('json', json)
  hljs.registerLanguage('markdown', markdown)
  hljs.registerLanguage('ruby', ruby)
github rubykit / kit / kit / libs / kit-doc-yard / assets / src / js / html.js View on Github external
$(() => {
  // Set up Handlebars.js
  Handlebars.registerHelper('isArray', isArray)
  Handlebars.registerHelper('isLocal', isLocal)
  Handlebars.registerHelper('isNonEmptyArray', isNonEmptyArray)
  Handlebars.registerHelper('groupChanged', groupChanged)
  Handlebars.registerHelper('nestingChanged', nestingChanged)
  Handlebars.registerHelper('showSummary', showSummary)

  // Set up Highlight.js
  hljs.configure({
    tabReplace: '    ', // 4 spaces
    languages: [] // disable auto-detect
  })
  hljs.registerLanguage('bash', bash)
  hljs.registerLanguage('css', css)
  hljs.registerLanguage('diff', diff)
  hljs.registerLanguage('http', http)
  hljs.registerLanguage('javascript', javascript)
  hljs.registerLanguage('json', json)
  hljs.registerLanguage('markdown', markdown)
  hljs.registerLanguage('ruby', ruby)
  hljs.registerLanguage('sql', sql)
  hljs.registerLanguage('xml', xml)
github vmware / admiral / ui / app / src / js / core / templateHelpers.js View on Github external
// Formats based on locale, like August 27, 2015 2:25 PM
      return moment(timestamp).format('LLL');
    }
  });

  Handlebars.registerHelper('booleanToYesNo', function(booleanValue) {
    if (booleanValue) {
      return i18n.t('app.template.list.true'); // yes
    } else {
      return i18n.t('app.template.list.false'); // no
    }
  });

  Handlebars.registerHelper('containerStatus', utils.containerStatusDisplay);

  Handlebars.registerHelper('formatBytes', function(valueBytes) {
    if (valueBytes && utils.isValidNonNegativeIntValue(valueBytes)) {
      return formatUtils.formatBytes(valueBytes);
    } else {
      return i18n.t('app.placement.list.unlimitedMemoryLimit');
    }
  });

  Handlebars.registerHelper('getDocumentId', utils.getDocumentId);

  /*
    Handlebars helper to display an array of strings to a readable string,
    by separating with comma
  */
  Handlebars.registerHelper('arrayToString', function(array) {
    if ($.isArray(array)) {
      return array.join(', ');
github Studio-Link / app / src / webui / src / app.js View on Github external
Handlebars.registerHelper("inc", function(value, options) {
  return parseInt(value) + 1;
});

Handlebars.registerHelper("mysip", function(value, options) {
  if (value.match("sip:(.+@studio-link.de)"))
    return value.match("sip:(.+@studio-link.de)")[1];
  return value;
});

Handlebars.registerHelper("myselect", function(channel, index, options) {
  if (channel == index)
    return 'selected';
});

Handlebars.registerHelper("times", function(n, block) {
  var accum = "";
  for (var i = 0; i < n; ++i) {
    block.data.index = i;
    block.data.first = i === 0;
    block.data.last = i === n - 1;
    accum += block.fn(this);
  }
  return accum;
});

$.fn.serializeObject = function() {
  var obj = {};
  var arr = this.serializeArray();
  arr.forEach(function(item, index) {
    if (obj[item.name] === undefined) {
      // New
github rubykit / kit / kit / libs / kit-doc-yard / assets / src / js / html.js View on Github external
$(() => {
  // Set up Handlebars.js
  Handlebars.registerHelper('isArray', isArray)
  Handlebars.registerHelper('isLocal', isLocal)
  Handlebars.registerHelper('isNonEmptyArray', isNonEmptyArray)
  Handlebars.registerHelper('groupChanged', groupChanged)
  Handlebars.registerHelper('nestingChanged', nestingChanged)
  Handlebars.registerHelper('showSummary', showSummary)

  // Set up Highlight.js
  hljs.configure({
    tabReplace: '    ', // 4 spaces
    languages: [] // disable auto-detect
  })
  hljs.registerLanguage('bash', bash)
  hljs.registerLanguage('css', css)
  hljs.registerLanguage('diff', diff)
  hljs.registerLanguage('http', http)
  hljs.registerLanguage('javascript', javascript)
github Studio-Link / app / src / webui / src / app.js View on Github external
var Handlebars = require("handlebars/runtime");

Handlebars.registerHelper("inc", function(value, options) {
  return parseInt(value) + 1;
});

Handlebars.registerHelper("mysip", function(value, options) {
  if (value.match("sip:(.+@studio-link.de)"))
    return value.match("sip:(.+@studio-link.de)")[1];
  return value;
});

Handlebars.registerHelper("inc", function(value, options) {
  return parseInt(value) + 1;
});

Handlebars.registerHelper("mysip", function(value, options) {
  if (value.match("sip:(.+@studio-link.de)"))
    return value.match("sip:(.+@studio-link.de)")[1];
  return value;
});

Handlebars.registerHelper("myselect", function(channel, index, options) {
  if (channel == index)
    return 'selected';
});

Handlebars.registerHelper("times", function(n, block) {
  var accum = "";
github vmware / admiral / ui / app / src / js / components / credentials / CredentialsRowRenderers.js View on Github external
};
    return $(CredentialsRowHighlightTemplate(model));
  }
};

var truncateContent = function(content) {
  content = content || '';

  if (content.length > MAX_TITLE_KEY_LENGTH) {
    content = content.substring(0, MAX_TITLE_KEY_LENGTH) + '...';
  }

  return content;
};

Handlebars.registerHelper('displayableCredentials', function(credentialObject) {

  if (credentialObject.type === constants.CREDENTIALS_TYPE.PASSWORD) {
    return formatUtils.escapeHtml(
      getUsernamePasswordString(credentialObject.username, credentialObject.password));

  } else if (credentialObject.type === constants.CREDENTIALS_TYPE.PRIVATE_KEY) {
    return formatUtils.escapeHtml(credentialObject.username) + ' / ' +
      '<div class="truncateText">' +
      formatUtils.escapeHtml(utils.maskValueIfEncrypted(credentialObject.privateKey)) +
      '</div>';

  } else if (credentialObject.type === constants.CREDENTIALS_TYPE.PUBLIC_KEY) {
    return '<div class="truncateText">' +
      formatUtils.escapeHtml(credentialObject.publicKey) +
      '</div>' +
      '<div class="truncateText">' +</div>
github vmware / admiral / ui / app / src / js / core / templateHelpers.js View on Github external
templateHelpers.register = function() {
  Handlebars.registerHelper('i18n', function(i18nKey) {
    i18nKey = Handlebars.Utils.escapeExpression(i18nKey);
    return i18next.t(i18nKey);
  });

  Handlebars.registerHelper('i18n-appmode-aware', function(i18nStandaloneKey, i18nEmbeddedKey) {
    var keyToUse;
    if (utils.isApplicationEmbedded()) {
      keyToUse = i18nEmbeddedKey;
    } else {
      keyToUse = i18nStandaloneKey;
    }

    keyToUse = Handlebars.Utils.escapeExpression(keyToUse);
    return i18n.t(keyToUse);
  });

  /*
    Handlebars helper to allow entering expressions to check if 2 objects are equal.
    Example: {{#ifEq model.propA 'someValue'}}...{{/ifEq}}
  */
  Handlebars.registerHelper('ifEq', function(a, b, options) {
github martijnversluis / ChordSheetJS / src / handlebars_helpers.js View on Github external
HandleBars.registerHelper('isTag', item => item instanceof Tag);

HandleBars.registerHelper('isComment', item => item.name === 'comment');

HandleBars.registerHelper('shouldRenderLine', (line, options) => {
  if (options.data.root.renderBlankLines) {
    return true;
  }

  return lineHasContents(line);
});

HandleBars.registerHelper('hasChordContents', hasChordContents);

HandleBars.registerHelper('hasTextContents', hasTextContents);

HandleBars.registerHelper('lineHasContents', lineHasContents);

HandleBars.registerHelper('lineClasses', (line) => {
  const classes = ['row'];

  if (!lineHasContents(line)) {
    classes.push('empty-line');
  }

  return classes.join(' ');
});

HandleBars.registerHelper('toUpperCase', line => line.toUpperCase());

HandleBars.registerHelper('paragraphClasses', (paragraph) => {
github ToneDen / Player / sdk / js / templates / helpers / msToTimestamp.js View on Github external
if(isNaN(minutes)) {
        minutes = '';
    }

    if(isNaN(seconds)) {
        return '';
    }

    if(seconds &lt; 10) {
        seconds = '0' + seconds;
    }

    return minutes + ':' + seconds;
}

Handlebars.registerHelper('msToTimestamp', msToTimestamp);

module.exports = msToTimestamp;