New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: inline function references #10
Comments
I was on the right track with template strings, by using tagged templates we can inline function calls. function tag (strings, ...values) {
return strings[0] + values[0]() + strings[1]
}
tag`Hello ${ a } world`
// hello cruel world
function a () {
return 'cruel'
} Since this relies on new syntax (ES6 tagged-tstrings can't be polyfilled) it should probably be released as a separate module. Hopefully that module can consume There is some complexity on how to do this though; it's different from how 1. replace function references (???)
2. parse html to vdom
3. reference the functions in the vdom |
Maybe some code can be borrowed from |
Just to put it out there: I'm interested in making this work because:
|
I recommend folks use https://github.com/shama/bel instead of this package; we've been working hard on it for the past two years to make sure it has all the features you could want to write inline HTML. Hope it's good; closing for now! |
I was wondering if anyone's got an idea on how to reference functions inline. What I'm trying to do is:
But this doesn't work. Does anyone have an ideas / suggestions on how to reference functions from within a string? I tried
String.raw
, but that seems to just stringify the function. Maybevirtual-html
could be extended to allow functions to be passed in as arguments after? Maybe this isn't possible at all (and needs macros or something to work). Thanks!See Also
The text was updated successfully, but these errors were encountered: