Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixir (here). Finally, first beta has been released!
- Source and installation instruction: https://github.com/grych/drab
- Home page: https://tg.pl/drab - with live examples
- Documentation with more examples: https://tg.pl/drab/docs
And of course it is available as a hex package.
In the meantime I’ve changed the API, so it is - I believe - easier to remember. If you think about webpage as a database which contains DOM objects, it is natural to query:
select(:text, from: "p:first")to get text of the first paragraph or
select(attr: :href, from: "a")for all links in the document,
update some object(s) with
update(css: :border, set: "3px solid red", on: this(sender)),
add new nodes or attributes
insert("<b>IMPORTANT</b>", before: "p:first"),
or remove something with
delete(class: "btn", from: "#the_button"),
and more, like synchronous modal which - launched on the server side - waits for user input.
Any suggestions, criticism, ideas welcome!