Skip to content

Commit b02daf5

Browse files
authored
New: Added use helper (fixes #504) (#505)
* New: Added use helper (fixes #504) * Missing import
1 parent b67304e commit b02daf5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

js/helpers.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Adapt from 'core/js/adapt';
22
import a11y from 'core/js/a11y';
3+
import data from 'core/js/data';
34
import logging from './logging';
45

56
const helpers = {
@@ -67,6 +68,14 @@ const helpers = {
6768
}
6869
},
6970

71+
use(id, block) {
72+
if (!block.fn) return;
73+
try {
74+
const model = data.findById(id);
75+
return block.fn(model.toJSON());
76+
} catch (err) {}
77+
},
78+
7079
/**
7180
* Equivalent to:
7281
* if (conditionA || conditionB)

0 commit comments

Comments
 (0)