Skip to content

Commit

Permalink
New: Added use helper (fixes #504) (#505)
Browse files Browse the repository at this point in the history
* New: Added use helper (fixes #504)

* Missing import
  • Loading branch information
oliverfoster authored Mar 25, 2024
1 parent b67304e commit b02daf5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Adapt from 'core/js/adapt';
import a11y from 'core/js/a11y';
import data from 'core/js/data';
import logging from './logging';

const helpers = {
Expand Down Expand Up @@ -67,6 +68,14 @@ const helpers = {
}
},

use(id, block) {
if (!block.fn) return;
try {
const model = data.findById(id);
return block.fn(model.toJSON());
} catch (err) {}
},

/**
* Equivalent to:
* if (conditionA || conditionB)
Expand Down

0 comments on commit b02daf5

Please sign in to comment.