Skip to content

Instantly share code, notes, and snippets.

@alco
Forked from 5HT/gist:7117914
Last active December 26, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alco/7118487 to your computer and use it in GitHub Desktop.
Save alco/7118487 to your computer and use it in GitHub Desktop.
# 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