mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
fbc23459fc
refs: https://github.com/TryGhost/Team/issues/759 - No matter what, a handlebars helper outputs a string. So if you return true, you'll always get 'true'. - SafeStrings are handlebars's way of passing around a string whilst also maintaining a record of the original value e.g. new SafeString(true) results in {string: true} - We need this for the match helper, so that we know when doing a comparison that we're meant to be comparing against a boolean true, not a string true - Therefore, we need to putput SafeStrings, but also process them when passed in The logic - Figuring out the correct logic here has been a little tricky but essentially: - {{match safestring}} with a single arg, will return true for any truthy value - {{match safestring "=" true}} does a direct comparison with the original value of the safe string, so if it was a boolean true, the match will be true else false - {{match (match something) "=" true}} will therefore work for any level of nesting - this can result in slightly inconsistent results, but feels correct and documentable This is documented extensively through the test cases |
||
---|---|---|
.. | ||
tpl | ||
asset.js | ||
author.js | ||
authors.js | ||
body_class.js | ||
cancel_link.js | ||
concat.js | ||
content.js | ||
date.js | ||
encode.js | ||
excerpt.js | ||
facebook_url.js | ||
foreach.js | ||
get.js | ||
ghost_foot.js | ||
ghost_head.js | ||
has.js | ||
img_url.js | ||
is.js | ||
lang.js | ||
link_class.js | ||
link.js | ||
match.js | ||
meta_description.js | ||
meta_title.js | ||
navigation.js | ||
page_url.js | ||
pagination.js | ||
plural.js | ||
post_class.js | ||
prev_post.js | ||
price.js | ||
products.js | ||
raw.js | ||
reading_time.js | ||
t.js | ||
tags.js | ||
title.js | ||
twitter_url.js | ||
url.js |