How to install erlydtl to make it usable in nitrogen?

585 Views Asked by At

I found, that erlydtl may be used with nitrogen.

Unfortunately, author hasn't described how he installed erlydtl to make it usable from nitrogen.

Probably somebody has ever faced with the same issue, I'm facing with. If so, please share your experience.

Thank you in advance.

2

There are 2 best solutions below

5
Alex Popov On BEST ANSWER

You should be able to just add ErlyDTL to your app's rebar.config:

 {erlydtl, ".*", {git, "git://github.com/erlydtl/erlydtl", {branch, master}}}

Then run ./rebar get-deps compile to install it in lib/ directory of your app and recompile.

Here's the step-by-step instructions

  1. Create a new folder to hold Nitrogen repo:

    • $ mkdir nitrogen-dtl
    • $ cd nitrodgen-dtl
  2. Clone Nitrogen from GitHub:

    • git clone https://github.com/nitrogen/nitrogen.git
    • cd nitrogen
  3. Build a slim (1) or a full (2) release called "dtltest" locateed in nitrogen-dtl folder:

    • make slim_inets PROJECT=dtltest (1)
    • make rel_inets PROJECT=dtltest (2)
  4. Edit rebar.config in dtltest folder:

    • cd ../dtltest
    • vi rebar.config
    • add the ErlyDTL as a dependency (and a comma to the line before it):

       {simple_bridge, ".*",   {git, "git://github.com/nitrogen/simple_bridge",{branch, master}}},
       {nprocreg,      ".*",   {git, "git://github.com/nitrogen/nprocreg",     {branch, master}}},
       {nitrogen_core, ".*",   {git, "git://github.com/nitrogen/nitrogen_core",{branch, master}}},
       {sync,          ".*",   {git, "git://github.com/rustyio/sync",          {branch, master}}},
       {erlydtl,      ".*",   {git, "git://github.com/erlydtl/erlydtl",       {branch, master}}}
      
  5. Download and compile dependencies with rebar:

    • ./rebar get-deps compile
  6. Start Nitrogen console, verify that application is running and try compiling an ErlyDTL template:

You should get a rendered template:

{ok,[<<"<html>">>,"Hallo Welt!",<<"</html>">>]}

If the template compiles, then ErlyDTL is installed correctly and you can use the code similar to the Gist you referenced in your application.

Cheers!

0
Namdak Tönpa On

In n2o you don't need to do anything. DTL is already included. All you need is using #dtl element:

main() ->
     #dtl{file = "index",
          app = review,
          bindings = [{body,"Hello"},{title,"Index"}]}.

Also n2o can be run natively on 17.0