Getting Domain Specific
Learn to create an HTML domain-specific language that generates templates from pure Elixir code.
Why use domain-specific language?
One of the most powerful ways to use macros is to build domain-specific languages (DSLs). DSLs can create a custom layer in the language to attack problems closer to our application domain. This can make our code easier to write and make it more clearly represent the problem being solved. With DSLs, we can codify our business requirements and operate at a shared level of abstraction with the callers of your library.
Creating an HTML DSL
Let’s extend the tools we’ve learned so far to create an HTML DSL by completing the following steps:
- First, we’ll introduce domain-specific languages.
- Second, we’ll build a complete HTML DSL that generates templates from pure Elixir code. During this process, we’ll uncover a few advanced macro features and learn how to apply them.
- Finally, we’ll review when and when not to use DSLs and ways to decide if they are a good fit for our library.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy