-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
How to reuse existing template literay when updating code in 'do action' #35
Comments
I thought about it but turns out it's more complicated because tagged templates accept strings and expressions as arguments: function update(strings, ...expressions) {
// ...
} So we could just concatenate everything but in this example where you have expressions inside: async function animate() {
${newCode}
} The output would be this because expressions are added after the strings: async function animate() {
}
// new code... You could use a function but I would have to think about it more. |
The |
Yeah it seems to work but the formatting needs work. |
I think we should make it as a normal function and call it instead passing template strings. If we do so, user has to do code formatting by himself. |
This is what I meant by using a function: <script>
const template = () => `
async function animate() {
${expression}
}
`
</script> I prefer the tagged template experience and you only have to check for expressions and merge them plus the formatting should be respected by the template-expression.mp4I'm working on other improvements so I can add them together and update the docs. |
Sounds good. Looking forward to it. BTW, thanks for quick reply. |
Closed 27982ad. |
Is there any way to pass the dynamic expression e.g.
I don't wanna repeat the same code again and again. I want to reuse the existing code because I have many lines of code. So how can we achieve this ? Any thoughts on this ?
The text was updated successfully, but these errors were encountered: