Enhancing API with HTML Attribute Support
Let’s extend our DSL to support an optional keyword list that is translated into tag attributes for each macro.
Supporting more tag attributes
To make the HTML library truly useful to the world, let’s add support for tag attributes such as class
and id
. Let’s extend the DSL to support an optional keyword list that gets translated into tag attributes for each macro.
For example, our goal is to support the following API:
Press + to interact
div id: "main" doh1 class: "title", do: text("Welcome!")div class: "row" dodiv class: "column" dop "Hello!"endendbutton onclick: "javascript: history.go(-1);" dotext "Back"endend
Replacing the tag
macro
Let’s revisit our Html
module from the last lesson and add support for tag attributes. Now, replace the tag/2
macro on line 4, as given in the project in the previous lesson: ...
Access this course and 1400+ top-rated courses and projects.