-
Notifications
You must be signed in to change notification settings - Fork 81
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
PostModifier for ScalaJS #538
Comments
Or is it possible to wrap the code with other code before execution in the browser? That would also be an option for me. |
Thank you for reporting! The Scala.js support is implemented with an entirely separate compile/evaluate pipeline making it difficult to support JS/JVM with a unified API. A JS Can you elaborate on your use-case? What would you concretely like to write in the markdown source and what should concrete render in the output? |
Is it an option to manually wrap the code with a function call? For example, if you have an ```scala mdoc:js
innerHTML {
div("hello")
}
``` |
I started to work on the outwatch documentation again and want to automatically generate the corresponding html code for static content: https://github.com/outwatch/outwatch#concatenating-strings It doesn't matter much if it's evaluated at build-time with node or in the browser (I'm on mobile now and can add some code later) Yes, wrapping with a visible shared function call would have been my next feasible workaround. |
Have you considered writing an invisible helper method called “div” that implements your desired functionality? |
Very interesting idea! This is what I tried:
But then I realized that return values are not printed in mdoc:js. I was only able to write the result into the current node:
I cannot put the Originally, I imagined having a custom modifier
Which adds a comment, containing the
|
One thing we could do is to make the node variable available through a global var or an implicit. Then you could update innerHTML. Do you think that would resolve your usecase? |
Yes, I think either would solve my case. An implicit sounds more elegant to me. Would there be any downsides? |
This makes it possible to implement helper methods that edit `innerHTML`. Fixes scalameta#538.
Sounds good. I opened #539 to add a new |
I think the use case would be to use the output of |
For reference, this is what I ended up with in the outwatch docs: |
For a dom dsl, I would like to show, which html code will be generated:
using a PostModifier, I want to render it into a temporary html element and extract the innerHTML of that element.
But as far as I understand, the PostModifier runs only on the JVM, so this is currently not possible.
Any ideas?
The text was updated successfully, but these errors were encountered: