Hey there!
I’m currently playing around with Meteor’s build plugins and would like to let the use decide how the code gets converted by adding binding handlers. This is what I’ve tried, but it obviously doesn’t work, as the file gets converted before the user has the chance to add a custom binding handler:
// This gets exported from the package and
// added to the registerBuildPlugin' sources
var ViewModel = (function () {
var _bindings = {}
return {
addHandler: function (name, handler) {
_bindings[name] = handler
},
getHandler: function (name) {
return _bindings[name]
}
}
})()
Plugin.registerSourceHandler('html.jsx', function () {
var handler = ViewModel.getHandler('visible')
// This should log 'Visible Handler'
console.log(handler())
})
// In the app, a user should be able to add binding handlers
ViewModel.addHandler('visible', function () {
return 'Visible Handler'
})
Do you have any idea what I could do to make this work? Maybe adding another file handler for binding handler which reads and eval
s the code?
Hope it’s clear what I want to do If not, let me know!