mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
✨ Added basic {{match}} helper
refs: https://github.com/TryGhost/Team/issues/759 - The match helper allows for basic equals and not equals comparisons, Example: {{match title "=" "Getting Started"}} {{match slug "!=" "welcome"}} - There's a lot more functionality we want to add here, so that it ends up being a replacement for {{#has}} - However, this first iteration is already useful, especially in the context of custom theme settings - Therefore we are adding it early, and will document it along with custom theme settings when that goes GA very soon
This commit is contained in:
parent
d7ae6e0138
commit
981f11da95
3 changed files with 1 additions and 21 deletions
|
@ -1,4 +1,3 @@
|
|||
const {labs} = require('../services/proxy');
|
||||
const {SafeString} = require('../services/rendering');
|
||||
|
||||
const logging = require('@tryghost/logging');
|
||||
|
@ -53,7 +52,7 @@ const handleMatch = (data, operator, value) => {
|
|||
return result;
|
||||
};
|
||||
|
||||
function match(...attrs) {
|
||||
module.exports = function match(...attrs) {
|
||||
// options = options || {};
|
||||
// options.hash = options.hash || {};
|
||||
// options.data = options.data || {};
|
||||
|
@ -101,18 +100,4 @@ function match(...attrs) {
|
|||
|
||||
// Else return the result as a SafeString Eg.{string: false} || {string: true}
|
||||
return new SafeString(result);
|
||||
}
|
||||
|
||||
module.exports = function matchLabsWrapper() {
|
||||
let self = this;
|
||||
let args = arguments;
|
||||
|
||||
return labs.enabledHelper({
|
||||
flagKey: 'matchHelper',
|
||||
flagName: 'Match helper',
|
||||
helperName: 'match',
|
||||
helpUrl: 'https://ghost.org/docs/themes/'
|
||||
}, () => {
|
||||
return match.apply(self, args);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -18,7 +18,6 @@ const messages = {
|
|||
// input for the "labs" setting value
|
||||
const BETA_FEATURES = [
|
||||
'activitypub',
|
||||
'matchHelper',
|
||||
'multipleProducts'
|
||||
];
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@ describe('Match helper', function () {
|
|||
sinon.restore();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
sinon.stub(labs, 'isSet').returns(true);
|
||||
});
|
||||
|
||||
function shouldCompileToExpected(templateString, hash, expected) {
|
||||
const template = handlebars.compile(templateString);
|
||||
const result = template(hash);
|
||||
|
|
Loading…
Add table
Reference in a new issue