-
-
Save alco/7118487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you need to invoke a macro at the top level of a module definition (i.e. not inside a "def"), | |
# extract it into another module | |
defmodule N2OMACRO do | |
defmacro element_base(mod) do quote do [ancestor: :element, module: unquote(mod), id: :undefined, | |
actions: [], class: [], style: [], source: [], | |
data_fields: [], aria_states: [], body: [], role: [], | |
tabindex: 0, show_if: false, html_tag: :undefined, title: []] end end | |
end | |
defmodule N2O do | |
require N2OMACRO | |
defrecord :dtl, N2OMACRO.element_base(:element_dtl) ++ [file: "index", bindings: [], app: __DIR__, folder: "priv/templates", ext: "html", bind_script: true] | |
defrecord :context, Record.extract(:context, from_lib: "n2o/include/wf.hrl") | |
defrecord :button, Record.extract(:button, from_lib: "n2o/include/wf.hrl") | |
defrecord :http_req, Record.extract(:http_req, from_lib: "cowboy/src/cowboy_req.erl") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment