<commit_before>/**
 * Link to helper
 *
 * usage:  {{#link-to 'routeName' class="btn btn-default"}}Text inside the link{{/link-to}}
 */
var hbs = require('hbs');

module.exports = function(we) {
  return function linkTo(name) {
    var options = arguments[arguments.length-1];
    var href = '';
    var route = {};

    if (we.router.routeMap.get[name]) {
      route = we.router.routeMap.get[name];
      var mapI = 1;
      for (var i = 0; i < route.map.length; i++) {
        // skip empty path parts linke  // and fist /
        if (!route.map[i]) continue;
        if (typeof route.map[i] == 'string') {
          href += '/' + route.map[i];
        } else if (arguments[mapI]){
          href += '/' + arguments[mapI];
          mapI++;
        } else {
          we.log.warn('Invalid or undefined argument: ' + arguments[i-1] +' ', route.map[i]);
        }
      }
    } else {
      we.log.warn('Route map not found: ' + name);
    }

    if (route.map && route.map.length && !href) href = '/';

    var attributes = [];
    // pass helper attributes to link element
    for (var attributeName in options.hash) {
      attributes.push(attributeName + '="' + options.hash[attributeName] + '"');
    }

    var l = '<a href="' + href + '" ' + attributes.join(' ') + ' >';
      l += options.fn(this);
    l += '</a>';

    return new hbs.SafeString(l);
  }
}<commit_msg>add suport to alias in link-to helper<commit_after>/**
 * Link to helper
 *
 * usage:  {{#link-to 'routeName' class="btn btn-default"}}Text inside the link{{/link-to}}
 */
var hbs = require('hbs');

module.exports = function(we) {
  return function linkTo(name) {
    var options = arguments[arguments.length-1];
    var href = '';
    var route = {};

    if (we.router.routeMap.get[name]) {
      route = we.router.routeMap.get[name];
      var mapI = 1;
      for (var i = 0; i < route.map.length; i++) {
        // skip empty path parts linke  // and fist /
        if (!route.map[i]) continue;
        if (typeof route.map[i] == 'string') {
          href += '/' + route.map[i];
        } else if (arguments[mapI]){
          href += '/' + arguments[mapI];
          mapI++;
        } else {
          we.log.warn('Invalid or undefined argument: ' + arguments[i-1] +' ', route.map[i]);
        }
      }
    } else {
      we.log.warn('Route map not found: ' + name);
    }

    if (route.map && route.map.length && !href) href = '/';

    // suport to route alias
    href = we.router.alias.resolvePath(href);

    var attributes = [];
    // pass helper attributes to link element
    for (var attributeName in options.hash) {
      attributes.push(attributeName + '="' + options.hash[attributeName] + '"');
    }

    var l = '<a href="' + href + '" ' + attributes.join(' ') + ' >';
      l += options.fn(this);
    l += '</a>';

    return new hbs.SafeString(l);
  }
}
{'fraction_non_alphanumeric': 0.1829011913104415, 'fraction_numerical': 0.002803083391730904, 'mean_word_length': 2.2223476297968396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1520539', 'n_tokens_mistral': 946, 'n_tokens_neox': 925, 'n_words': 230}