registers a helper, which could be used in the templates
@example
{{#foreach}}
{{#if $last}} console.log('this was the last element') {{/if}}
{{#if $notLast}} console.log('this was not the last one') {{/if}}
{{/foreach}}
350791
function registerHandlebarsHelpers() {
  Handlebars.registerHelper('foreach', function(arr, options) {
    if (options.inverse && !arr.length) {
      return options.inverse(this);
    }
    return arr
      .map(function(item, index) {
        item.$index = index;
        item.$first = index === 0;
        item.$last = index === arr.length - 1;
        item.$notFirst = index !== 0;
        item.$notLast = index !== arr.length - 1;
        return options.fn(item);
      })
      .join('');
  });
}
750932
public function addJsRequirement($js, LambdaHelper $helper = null)
    {
        $js  = trim($js);
        $key = md5($js);

        if (!isset(self::$jsRequirements[$key])) {
            if ($helper !== null) {
                $js = $helper->render($js);
            }

            self::$jsRequirements[$key] = $js;
        }
    }
1254143
function pluginify(name, classname, iterate = true, shorthand = false, ignoreWarning = false) {

  if ( typeof name == 'undefined' || typeof classname == 'undefined' ) {
    console.warn('Pluginify requires a name and class reference');
    return false;
  }

  if (!window.jQuery && !ignoreWarning) {

    console.error(`Pluginify tried to turn "${name}" into a jQuery plugin, but jQuery was not found.`)

  } else {

    let dataName = `__${name}`;
    let old = $.fn[name];
    let warned = false;

    $.fn[name] = function (...option) {

      if (iterate) {

        return this.each((index, element) => {

          let $this = $(element);
          let data = $this.data(dataName);
          let options = $.extend({}, classname.defaults, $this.data(), typeof option === 'object' && option);

          if (!data) {
            $this.data(dataName, (data = new classname(this, options)));
          } else {
            if (!warned) {
              console.warn($this[0],  " These items have already been set to iterate already");
            }
            warned = true;
          }

          if (typeof option === 'string') {
            data[option]();
          }

        });

      } else {

        let $this = $(this);
        let data = $this.data(dataName);
        let options = $.extend({}, classname.defaults, $this.data(), typeof option === 'object' && option);

        if (!data) {
          $this.data(dataName, (data = new classname(this, options)));
        } else {
          if (!warned) {
            console.warn($this[0],  " These items have already been set to iterate already");
          }
          warned = true;
        }

        if (typeof option === 'string') {
          data[option]();
        }

        return data;

      }

    };

    // Generate a shorthand as $.pluginName
    if (shorthand) {
      $[name] = (options) => $({})[name](options);
    }

    // - No conflict
    $.fn[name].noConflict = () => $.fn[name] = old;

  }
}
1279680
protected function registerBladeExtensions()
	{
		$blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler();

		$blade->extend(function($value, $compiler)
		{
			$matcher = $compiler->createMatcher('javascripts');

			return preg_replace($matcher, '$1<?php echo javascript_include_tag$2; ?>', $value);
		});

		$blade->extend(function($value, $compiler)
		{
			$matcher = $compiler->createMatcher('stylesheets');

			return preg_replace($matcher, '$1<?php echo stylesheet_link_tag$2; ?>', $value);
		});
	}
278729
function(value) {
                this.lastValue = this.currentValue;
                this.currentValue = value;
                this.setter.call(this.target, this.target, value, this);
            }
210502
function(type, callbacks) {
        $.each(callbacks, function(i, callback) {
            this.addHook(type, callback);
        }.bind(this));
    }
595365
function register() {
    ko.extenders['searchArray'] = searchArrayExtension;
    ko.components.register('grid', {
        template: template,
        viewModel: viewModel
    });
}
540854
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;
}
1267602
public function register()
    {
        $this->helper_callbacks = array();
        $arguments= func_get_args();
        if(count($arguments) > 0){
            foreach($arguments as $argument){
                if($argument instanceof Plugin){ //this is a plugin object
                    $callback = $argument->getEventHelperCallback($this->getName());
                    if(is_callable($callback)){
                        $this->helper_callbacks[] = $callback;
                    }                 
                }
                else if(is_callable($argument)){ //this is a closure
                    $this->helper_callbacks[] = $argument;
                }
            }
        }

        return $this; //return the event object reference to allow chainable calls
    }
191980
function (callback) {
        after("helper.after", function () {
            return bluebird.resolve()
                .then(function() {
                    if (_.isFunction(callback)) {
                        return callback();
                    }
                })
                .then(helper.stop.bind(helper));
        });
    }
1258561
function tpl_apply_with_register_helper(Handlebars, template_path, data_obj, dest_file_path) {
	var rs = fs.createReadStream(template_path, {bufferSize: 11}); 
	var bufferHelper = new BufferHelper();

	rs.on("data", function (trunk){
			bufferHelper.concat(trunk);
	});

	rs.on("end", function () {
		var source = bufferHelper.toBuffer().toString('utf8');
		var template = Handlebars.compile(source);
	
    // log(template);
		
		var content = template(data_obj);

		fs.writeFile(dest_file_path, content , function (err) {
		  if (err) throw err;
		  log('It\'s saved!');
		});

	});
}
929659
function helper(context, helpers, helperName, args) {
  if (typeof helpers[helperName] !== 'function') {
    return '';
  }
  try {
    const out = helpers[helperName].apply(context, args);
    return out || '';
  } catch (e) {
    return '';
  }
}
1103316
function(name) {
        var self = this, found = false;
        if (!name) { return found; }
        utils.each(this._handlers, function(i) {
            if (name === this.name) {
                self._handlers.splice(i, 1);
                return (found = true, false);
            }
        });
        if (!found) {
            utils.each(this._lastHandlers, function(i) {
                if (name === this.name) {
                    self._lastHandlers.splice(i, 1);
                    return (found = true, false);
                }
            });
        }
        return found;
    }
9986
function () {

    /*  Tagging arbitrary member as $final
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

        $assertThrows (function () {

            var A = $prototype ({
                        constructor: $final (function () {}) })

            var B = $extends (A, {
                        constructor: function () {} }) },   // will throw Error

            _.matches ({ message: 'Cannot override $final constructor' }))

    /*  Tagging whole prototype as $final
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

        $assertThrows (function () {

            var A = $prototype ($final ({}))
            var B = $extends (A) }, // will throw Error

             _.matches ({ message: 'Cannot derive from $final-marked prototype' })) }
539448
function (view, locals, context, isAsync) {
    var helpers = {};
    lazy.extend(helpers, this.options.helpers);
    lazy.extend(helpers, this._.helpers.sync);

    if (isAsync) lazy.extend(helpers, this._.helpers.async);
    lazy.extend(helpers, locals.helpers);

    // build the context to expose as `this` in helpers
    var thisArg = {};
    thisArg.options = lazy.extend({}, this.options, locals);
    thisArg.context = context || {};
    thisArg.context.view = view;
    thisArg.app = this;

    // bind template helpers to the instance
    locals.helpers = utils.bindAll(helpers, thisArg);
  }
386986
function(template) {
      // ensure template is decorated (lets' things like <tr template ...> work)
      HTMLTemplateElement.decorate(template);
      // ensure a default bindingDelegate
      var syntax = this.syntax || (!template.bindingDelegate &&
          this.element.syntax);
      var dom = template.createInstance(this, syntax);
      var observers = dom.bindings_;
      for (var i = 0; i < observers.length; i++) {
        this.registerObserver(observers[i]);
      }
      return dom;
    }
1033064
function () {
                var children = [],
                    addedDescriptors = [],
                    i, child;

                if (this.$defaultContentName && this.$defaultTemplateName) {
                    throw "both $defaultContentName and $defaultTemplateName are defined";
                }

                var desc;

                function addChildren(childrenFromDescriptor, fromDescriptor) {

                    // don't add children with the same descriptor twice
                    for (var j = 0; j < childrenFromDescriptor.length; j++) {
                        child = childrenFromDescriptor[j];
                        child.$fromDescriptor = fromDescriptor;

                        if (child.$createdByTemplate || _.indexOf(addedDescriptors, child.$descriptor) === -1) {
                            children.push(child);
                            if (child.$descriptor) {
                                addedDescriptors.push(child.$descriptor);
                            }
                        }
                    }
                }

                for (var d = 0; d < this.$internalDescriptors.length; d++) {
                    desc = this.$internalDescriptors[d];
                    addChildren(this._getChildrenFromDescriptor(desc, this, null, this), "intern");
                }

                var externalDescriptorChildren;

                if (this.$defaultTemplateName) {
                    var templateBlock;

                    // go through all children from the external descriptor
                    // and check if a template block with the name $defaultTemplateName

                    for (i = 0; i < this.$descriptor.childNodes.length; i++) {
                        var node = this.$descriptor.childNodes[i];

                        if (node.nodeType === 1 &&
                            node.getAttribute("name") === this.$defaultTemplateName &&
                            this.$stage.$applicationContext.getFqClassName(node.namespaceURI, this._localNameFromDomNode(node), true) === "js/core/Template") {

                            templateBlock = node;
                            break;
                        }
                    }

                    if (!templateBlock && this.$descriptor) {
                        templateBlock = this.createComponent(Component.Template, {
                            name: this.$defaultTemplateName
                        }, this.$descriptor);

                        externalDescriptorChildren = [templateBlock];
                    }

                }

                externalDescriptorChildren = externalDescriptorChildren || this._getChildrenFromDescriptor(this.$descriptor);


                if (this.$defaultContentName && this.$descriptor) {
                    // check if content block is already defined
                    var contentBlock,
                        internAndExternalChildren = children.concat(externalDescriptorChildren);


                    for (i = 0; i < internAndExternalChildren.length; i++) {
                        child = internAndExternalChildren[i];

                        if (child instanceof Component.Content && child.$.name === this.$defaultContentName) {
                            // content block already defined
                            contentBlock = child;
                            break;
                        }
                    }

                    if (!contentBlock) {
                        // create a content block and move all children in a js.core.Content Block
                        contentBlock = this.createComponent(Component.Content, {
                            name: this.$defaultContentName
                        });

                        // add all children to content block
                        for (i = 0; i < externalDescriptorChildren.length; i++) {
                            contentBlock.addChild(externalDescriptorChildren[i]);
                        }

                        externalDescriptorChildren = [contentBlock];
                    }

                }

                addChildren(externalDescriptorChildren, "external");

                var extraChildren = this.createChildren();
                if (extraChildren) {
                    addChildren(extraChildren, "extra");
                }

                this._initializeChildren(children);

                this._childrenInitialized();

                this._initializeXamlEventAttributes(this.$xamlDefaults, this);
                this._initializeXamlEventAttributes(this.$xamlAttributes, this.$rootScope);
            }