How to use the escapeExpression function from handlebars

Find comprehensive JavaScript handlebars.escapeExpression code examples handpicked from public code repositorys.

32
33
34
35
36
37
38
39
40
41
	trialEndAt = new Date(company.get('trialEndDate')).toISOString();
}
if (company && company.get('testGroups')) {
	// this has to be a string that looks like an array in javascript
	abTest = '[' + Object.keys(company.get('testGroups')).map(key => {
		const safe = Handlebars.escapeExpression(`${key}|${company.get('testGroups')[key]}`);
		return `"${safe}"`;
	}).join(',') + ']';
} else {
	abTest = '[]';
fork icon33
star icon58
watch icon12

20
21
22
23
24
25
26
27
28
29
}, 
formatDate: function (date, format) {
    return moment(date).utc().format(format)
},
bold:function(text){
  var result = "<b>" + Handlebars.escapeExpression(text) + "</b>";
  return new Handlebars.SafeString(result);
},

editIcon: function (wcUser, loggedUser, wcId, lineId, wcOrder, floating = true) {
fork icon0
star icon0
watch icon2

3
4
5
6
7
8
9
10
11
12

let attributes = []

Object.keys(options.hash).forEach(key => {
	let escapedKey = Handlebars.escapeExpression(key)
	let escapedValue = Handlebars.escapeExpression(options.hash[key])
	attributes.unshift(escapedKey + '="' + escapedValue + '"')
})

attributes = attributes.join(' ')
fork icon0
star icon0
watch icon0

17
18
19
20
21
22
23
24
25
26
}

const icon = icons[sortType]
const type = types[sortType]

const address = Handlebars.escapeExpression(`?_sort&column=${field}&type=${type}`)

const output = `<a href="${address}"><i class="${icon}"></i>    </a>`;

return new Handlebars.SafeString(output);
fork icon0
star icon0
watch icon0

18
19
20
21
22
23
24
25
26
27
28
29


        const icon = icons[sortType];
        const type = types[sortType];


        //bảo mật
        const href = Handlebars.escapeExpression(`?_sort&column=${field}&type=${type}`)
        const output = `<a href="${href}">${icon}</a>`;
        return new Handlebars.SafeString(output);
    }
}
fork icon0
star icon0
watch icon0

17
18
19
20
21
22
23
24
25
26
      desc: 'asc',
  }
  
  const icon = icons[sortType];
  const type = types[sortType];
  const href = Handlebars.escapeExpression(`./admin?_sort&column=${field}&type=${type}`);

  const output = `<a href="${href}">
  <span class="${icon}"></span>
</a>`;
fork icon0
star icon0
watch icon0

16
17
18
19
20
21
22
23
24
25
};

const icon = icons[sortType];
const type = types[sortType];

const href = Handlebars.escapeExpression(
  `?_sort&column=${filed}&type=${type}`
);

const output = `<a href="${href}"><i class="${icon}"></i></a>`;
fork icon0
star icon0
watch icon0

17
18
19
20
21
22
23
24
25
26
  asc: 'desc',
  desc: 'asc',
}
const type = types[sortType];
const icon = icons[sortType];
const addr = Handlebars.escapeExpression(`?_sort&column=${field}&type=${type}`);
const output = `<a href="${addr}">
    <i class="fa-solid ${icon} ms-2"></i>
  </a>`
return new Handlebars.SafeString(output);
fork icon0
star icon0
watch icon0