src/helpers/pattern.js
function registerPatternHelpers(options) {
  const Handlebars = options.handlebars;
  if (Handlebars.helpers.pattern) {
    DrizzleError.error(
      new DrizzleError(
        '`pattern` helper already registered',
        DrizzleError.LEVELS.WARN
      ),
      options.debug
    );
  }
  /**
   * The `pattern` helper allows the embedding of patterns anywhere
   * and they can get their correct local context.
   */
  Handlebars.registerHelper('pattern', (id, rootContext, opts) => {
    const renderedTemplate = renderPatternPartial(
      id,
      rootContext.drizzle,
      Handlebars
    );
    return renderedTemplate;
  });

  if (Handlebars.helpers.patternSource) {
    DrizzleError.error(
      new DrizzleError(
        '`patternSource` helper already registered',
        DrizzleError.LEVELS.WARN
      ),
      options.debug
    );
  }
  /**
   * Similar to `pattern` but the returned string is HTML-escaped.
   * Can be used for rendering source in `<pre>` tags.
   */
  Handlebars.registerHelper('patternSource', (id, rootContext, opts) => {
    const renderedTemplate = renderPatternPartial(
      id,
      rootContext.drizzle,
      Handlebars
    );
    const sourceMarkup = beautify(renderedTemplate, options.beautifier);
    return Handlebars.Utils.escapeExpression(sourceMarkup);
  });
  return Handlebars;
}
function registerPatternHelpers(options) {
  const Handlebars = options.handlebars;
  if (Handlebars.helpers.pattern) {
    DrizzleError.error(
      new DrizzleError(
        '`pattern` helper already registered',
        DrizzleError.LEVELS.WARN
      ),
      options.debug
    );
  }
  /**
   * The `pattern` helper allows the embedding of patterns anywhere
   * and they can get their correct local context.
   */
  Handlebars.registerHelper('pattern', (id, rootContext, opts) => {
    const renderedTemplate = renderPatternPartial(
      id,
      rootContext.drizzle,
      Handlebars
    );
    return renderedTemplate;
  });

  if (Handlebars.helpers.patternSource) {
    DrizzleError.error(
      new DrizzleError(
        '`patternSource` helper already registered',
        DrizzleError.LEVELS.WARN
      ),
      options.debug
    );
  }
  /**
   * Similar to `pattern` but the returned string is HTML-escaped.
   * Can be used for rendering source in `<pre>` tags.
   */
  Handlebars.registerHelper('patternSource', (id, rootContext, opts) => {
    const renderedTemplate = renderPatternPartial(
      id,
      rootContext.drizzle,
      Handlebars
    );
    const sourceMarkup = beautify(renderedTemplate, options.beautifier);
    return Handlebars.Utils.escapeExpression(sourceMarkup);
  });
  return Handlebars;
}
function registerPatternHelpers ( options ) { const Handlebars = options . handlebars ; if ( Handlebars . helpers . pattern ) { DrizzleError . error ( new DrizzleError ( '`pattern` helper already registered' , DrizzleError . LEVELS . WARN ) , options . debug ) ; } /**
   * The `pattern` helper allows the embedding of patterns anywhere
   * and they can get their correct local context.
   */ Handlebars . registerHelper ( 'pattern' , ( id , rootContext , opts ) => { const renderedTemplate = renderPatternPartial ( id , rootContext . drizzle , Handlebars ) ; return renderedTemplate ; } ) ; if ( Handlebars . helpers . patternSource ) { DrizzleError . error ( new DrizzleError ( '`patternSource` helper already registered' , DrizzleError . LEVELS . WARN ) , options . debug ) ; } /**
   * Similar to `pattern` but the returned string is HTML-escaped.
   * Can be used for rendering source in `<pre>` tags.
   */ Handlebars . registerHelper ( 'patternSource' , ( id , rootContext , opts ) => { const renderedTemplate = renderPatternPartial ( id , rootContext . drizzle , Handlebars ) ; const sourceMarkup = beautify ( renderedTemplate , options . beautifier ) ; return Handlebars . Utils . escapeExpression ( sourceMarkup ) ; } ) ; return Handlebars ; }
Register some drizzle-specific pattern helpers
Register some drizzle - specific pattern helpers