From the course: Code Clinic: Clojure
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Parsing HTML
- [Man] In this video, we'll load the base HTML page and insert the HTML regenerating into the proper location. First, I'll use a macro from enlive called deft template. Its first argument is it takes a name, we'll call this add table, cuz we'll be adding tables. Its next argument is the HTMl file we wanna load. So I'll use the string website/programs/graphic-design.htm. Next this macro takes any parameters that we wanna pass in. So I'll use table HTML data, and when we use this macro we'll pass in the data that generate table returns. Next, the body of this macro takes pairs of a selector on the left, and what we wanna do with it on the right. First, for the selector portion, I'll use a vector with the article keyword which will look for the article tag. Then I'll use pound main content to look for an article tag with the ID main content. This mimics CSS selectors. You can also use classes and so on. Now after that, we'll implement what we want to do. We'll use enlive's append…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.