May 2018
Beginner to intermediate
290 pages
6h 43m
English
Let’s return to our arithmetic-if macro:
| | (defmacro arithmetic-if [n pos zero neg] |
| | (list 'cond (list 'pos? n) pos |
| | (list 'zero? n) zero |
| | :else neg)) |
We’re working pretty hard to produce that cond expression. After all, it’s just some boilerplate code with a few custom values slotted in here and there. If this sounds like a familiar problem, it should. People who develop web applications frequently need to mix context-specific data—perhaps today’s date or the current share price of Anacott Steel—into a skeleton of otherwise static HTML.
The solution in both situations is the same: use a template. You cook up the static bulk of your output as a sort of skeleton, which includes special markers that ...
Read now
Unlock full access