Attaches custom template helper methods  render: function(string) Replaces the tag with the (html) at the specified location.  translate: function(string) Resolves a given key with the value for the current language
483734
function(options) {
    return _.merge(options.data, {

      // Render helper method. Allows to render
      // partials within template files.
      render: function(filename) {
        var filepath = options.cwd + filename;
        var template = readTemplateFile({ src: [ filepath ] });
        return grunt.template.process(template, options);
      },

      // Translation helper method.
      // Allows resolving keys within a translation file.
      translate: function(key) {
        var translation = options.translations[key];

        if (!translation) {
          grunt.fail.warn('No translation found for key:', key);
        }
        return translation;
      }
    });
  }
536107
function ( key, parameters ) {
			var message = key.toLocaleString();
			// FIXME: This changes the state of the I18N object,
			// should probably not change the 'this.parser' but just
			// pass it to the parser.
			this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default'];
			if( message === '' || message === '*' ) {
				
				if ( ( mode == "php" ) && ( message != '*' ) ) {

					$.post( "svc/backend/i18n/", { missing: key, lang : $.i18n().locale , layout : pageInfo["layout"] } );
				}
				
				message = key;
			}
			var result =  this.parser.parse( message, parameters );
			if ( result.substr(0,6) == 'UTF8: ') result = result.substr(6)
			return result;
		}
1233260
function templateRenderer(language, describe, spec) {

    var template,
        className,
        methodName;

    /**
     * Return when no language specified.
     */
    if (!language) {
        return;
    }

    /**
     * Converts to CamelCase.
     *
     * 'This is my test' -> ThisIsMyTest
     */
    function toCamelCase(str) {
        return str.replace(/\w\S*/g, function(txt) {
            return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
        }).replace(/\s/g, '');
    }

    /**
     * Converts to underscore.
     *
     * 'This is my test' -> This_Is_My_Test
     */
    function toUnderScore(str) {
        return str.replace(/\s/g, '_');
    }

    /**
     * Converts first char to lower case.
     */
    function firstToLowerCase(str) {
        return str.substr(0, 1).toLowerCase() + str.substr(1);
    }

    /**
     * Converts describes and specks to language specific derivative.
     */
    switch (language) {
        case 'java':
            describe = toCamelCase(describe) + 'Test';
            spec = firstToLowerCase(toCamelCase(spec));
            break;
        case 'php':
            describe = toCamelCase(describe) + 'Test';
            spec = 'test' + toCamelCase(spec);
            break;
        case 'phpspec':
            describe = toCamelCase(describe) + 'Spec';
            spec = 'it_' + toUnderScore(spec);
            break;
        case 'junit':
            className = toCamelCase(describe) + 'Test';
            methodName = firstToLowerCase(toCamelCase(spec));
            break;
    }

    /**
     * Get template replace DESCRIBE/SPEC.
     */
    template = String(fs.readFileSync(__dirname + "/templates/" + language + ".tpl"));
    return template
        .replace("{{DESCRIBE}}", describe)
        .replace("{{SPEC}}", spec)
        .replace("{{CLASS}}", className)
        .replace("{{METHOD}}", methodName);

}
662311
def render(before_string, after_string)
      before_node = ::Nokogiri::HTML.fragment(before_string)
      after_node = ::Nokogiri::HTML.fragment(after_string)
      patch = create_patch(before_node, after_node)
      apply_patch(patch, before_node)
    end
450276
function compile(func) {
  return function() {
    return '(' + func.toString() + ')(' +
      utils.map(arguments, JSON.stringify).join(', ') + ');';
  }
}
525693
function handleLocaleChange({ locale, languageTag }) {
      const newTag = normalize( languageTag );
      if( newTag === tags[ locale ] ) {
         return;
      }
      tags[ locale ] = newTag;
      callbacks[ locale ] = callbacks[ locale ] || [];
      callbacks[ locale ].forEach( f => { f( languageTag ); } );
   }
1225391
function replaceLocale(context, payload) {
      context.commit({
        type: 'REPLACE_LOCALE',
        locale: payload.locale,
        translations: payload.translations
      });
    }
422255
function(template, context, partials) {
        if(!this.includes("#", template) && !this.includes("^", template)) {
          return template;
        }

        var that = this;
        // CSW - Added "+?" so it finds the tighest bound, not the widest
        var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
                "\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
                "\\s*", "mg");

        // for each {{#foo}}{{/foo}} section do...
        return template.replace(regex, function(match, type, name, content) {
          var value = that.find(name, context);
          if(type == "^") { // inverted section
            if(!value || that.is_array(value) && value.length === 0) {
              // false or empty list, render it
              return that.render(content, context, partials, true);
            } else {
              return "";
            }
          } else if(type == "#") { // normal section
            if(that.is_array(value)) { // Enumerable, Let's loop!
              return that.map(value, function(row) {
                return that.render(content, that.create_context(row),
                  partials, true);
              }).join("");
            } else if(that.is_object(value)) { // Object, Use it as subcontext!
              return that.render(content, that.create_context(value),
                partials, true);
            } else if(typeof value === "function") {
              // higher order section
              return value.call(context, content, function(text) {
                return that.render(text, context, partials, true);
              });
            } else if(value) { // boolean section
              return that.render(content, context, partials, true);
            } else {
              return "";
            }
          }
        });
      }
897821
def optional_assignment_tag(func=None, takes_context=None, name=None):
    
    def dec(func):
        params, varargs, varkw, defaults = getargspec(func)

        class AssignmentNode(TagHelperNode):
            def __init__(self, takes_context, args, kwargs, target_var=None):
                super(AssignmentNode, self).__init__(takes_context, args, kwargs)
                self.target_var = target_var

            def render(self, context):
                resolved_args, resolved_kwargs = self.get_resolved_arguments(context)
                output = func(*resolved_args, **resolved_kwargs)
                if self.target_var is None:
                    return output
                else:
                    context[self.target_var] = output
                return ''

        function_name = (name or
                         getattr(func, '_decorated_function', func).__name__)

        def compile_func(parser, token):
            bits = token.split_contents()[1:]
            if len(bits) < 2 or bits[-2] != 'as':
                target_var = None
            else:
                target_var = bits[-1]
                bits = bits[:-2]
            args, kwargs = parse_bits(parser, bits, params,
                varargs, varkw, defaults, takes_context, function_name)
            return AssignmentNode(takes_context, args, kwargs, target_var)

        compile_func.__doc__ = func.__doc__
        register.tag(function_name, compile_func)
        return func
    if func is None:
        # @register.assignment_tag(...)
        return dec
    elif callable(func):
        # @register.assignment_tag
        return dec(func)
    else:
        raise TemplateSyntaxError("Invalid arguments provided to assignment_tag")
565555
function makeTranslation (original, replacement) {
    let translation = new Map()
    Array.prototype.forEach.call(original, function setMap (source, index) {
      translation.set(source, replacement[index] || '')
    })

    return function (string) {
      return Array.prototype.map.call(string, function replace (ch) {
        return translation.has(ch) ? translation.get(ch) : ch
      }).join('')
    }
  }
157780
def displayhtml(public_key,
                attrs,
                use_ssl=False,
                error=None):
    """"""

    error_param = ''
    if error:
        error_param = '&error=%s' % error

    if use_ssl:
        server = API_SSL_SERVER
    else:
        server = API_SERVER

    if 'lang' not in attrs:
        attrs['lang'] = get_language()[:2]

    return render_to_string(
        WIDGET_TEMPLATE,
        {'api_server': server,
         'public_key': public_key,
         'error_param': error_param,
         'lang': attrs['lang'],
         'options': mark_safe(json.dumps(attrs, indent=2))
         })
1139413
function replaceYield(tmpl, html) {
      // do nothing if no yield
      if (!reHasYield.test(tmpl)) { return tmpl }

      // be careful with #1343 - string on the source having `$1`
      var src = {};

      html = html && html.replace(reYieldSrc, function (_, ref, text) {
        src[ref] = src[ref] || text;   // preserve first definition
        return ''
      }).trim();

      return tmpl
        .replace(reYieldDest, function (_, ref, def) {  // yield with from - to attrs
          return src[ref] || def || ''
        })
        .replace(reYieldAll, function (_, def) {        // yield without any "from"
          return html || def || ''
        })
    }
605143
function translateElement(element, locale) {
    var $element = $(element),
        keyPath = $element.data('translate');

    var translation = getTranslation(keyPath, locale);
    if(translation) {
      $(element).text(translation);
    }
  }
399586
function renderTemplate(template, context) {
    var esc = $(document.createElement('div'));

    function handle(ph, escape) {
      var cur = context;
      $.each(ph.split('.'), function() {
        cur = cur[this];
      });
      return escape ? esc.text(cur || "").html() : cur;
    }

    return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
      return handle(arguments[2], arguments[1] == '%' ? true : false);
    });
  }
751656
function templateFunc(str, data) {

  const func = function(obj) {
    return str.replace(/<%=([^%]*)%>/g, match => {
      //match t("...")
      let s = match.match(/t\s*\(([^)]+)\)/g);
      //replace with translation
      if (s.length) {
        s = obj.t(s[0].match(/"([^"]+)"/g)[0].split('"').join(""));
      }
      //use object[name]
      else {
        s = match.match(/([a-z\-A-Z]+([a-z\-A-Z0-9]?[a-zA-Z0-9]?)?)/g)[0];
        s = obj[s] || s;
      }
      return s;
    });
  };
  // Figure out if we're getting a template, or if we need to
  // load the template - and be sure to cache the result.
  const fn = !/<[a-z][\s\S]*>/i.test(str) ? templates[str] = templates[str] || templateFunc(globals.templates[str]) : func;

  // Provide some basic currying to the user
  return data ? fn(data) : fn;
}
287612
function html(options) {
  return Object.assign(function (context) {
    var defaultOpts = {
      filename: 'index.html',
      template: 'templates/index.html',
      showErrors: false
    };

    // Merge the provided html config into the context
    var html = context.html || defaultOpts;

    /* Warning: Thar be mutation ahead! */
    /* eslint-disable fp/no-mutation */
    context.html = (0, _deepmerge2.default)(html, options, { clone: true });
    /* eslint-enable fp/no-mutation */

    // Return empty config snippet (configuration will be created by the post hook)
    return {};
  }, { post: postConfig });
}
519669
function renderTemplate(template, css, data={}){
  
    // assign css
    data.inlinecss = css;

    // render template - use custom escape function to handle linebreaks!
    return _ejs.render(template, data, {
        escape: function(text){
            if (!text){
                return '';
            }

            // apply generic escape function
            text = _ejs.escapeXML(text);

            // linebreaks
            text = text.replace(/\n/g, '<br />');

            return text;
        }
    });
}