For those just now encountering this series, you'll want to start with Part 1, and at least have Introduction to Nitrogen open in another tab.
Slide 75: Extending Nitrogen: Custom Actions - Part 1
As described in the tutorial, create the file for the action, with its dummied code.
bash-4.1$ ./dev action my_action
Created action: ./site/src/actions/action_my_action.erl
Remember to recompile!
bash-4.1$
Slide 76: Extending Nitrogen: Custom Actions - Part 2
OK, a record and one mandatory function. Again following the suggestion of the comment, I move the record to ${Root}/include/records.hrl
. I also change the dummy code in render_action/1
to match the tutorial example. Not much to typo there, but let's see...
Nonetheless, I manage to make one: the dummy function in action_my_action.erl has an underscore prefixed to the matching variable _Record
, but since we actually use that variable in the function body, it must not be anonymous (as an underscore declares it). Fix that, and I get a clean compile:
bash-4.1$ ./dev compile
:: MAKE - site
Recompile: ./src/my_page
Recompile: ./src/login
Recompile: ./src/chat
Recompile: ./src/elements/element_my_element
Recompile: ./src/actions/action_my_action
:: MAKE - ./site
:: Done!
Slide 77: Extending Nitrogen: Custom Actions - Part 3
Now to use it in my_page.erl
. Yup, that worked, after I removed an extraneous ->
I'd introduced (what was I thinking?).