template error

12 views
Skip to first unread message

Bernie

unread,
May 8, 2015, 10:41:39 AM5/8/15
to nitro...@googlegroups.com
Hi,

I'm getting the error below when I try to add pages from the demos section e.g. demos_dragdrop.erl or demos_wizard.erl.
What I did was download the latest Linux binary and copy/paste the page source from either the View Source link on nitrogenproject or Github to add the new pages. Both result in the same error.

My only change was to the path from
main() -> #template { file="./templates/demos46.html" }.
to
main() -> #template { file="./site/templates/demos46.html" }.
so it finds the template in the first place.

I have found a few earlier posts about the same error, but no definitive solution. Has somebody figure one out?

Thanks,
Bernie

error:{badmatch,{error,nofile}}
--------------------------
[{element_template,'-convert_callback_tuple_to_function/5-fun-0-',4,
                   [{file,"src/elements/layout/element_template.erl"},
                    {line,172}]},
 {element_function,call_next_function,1,
                   [{file,"src/elements/other/element_function.erl"},
                    {line,35}]},
 {wf_render_elements,call_element_render,3,
                     [{file,"src/lib/wf_render_elements.erl"},{line,130}]},
 {wf_render_elements,render_element,1,
                     [{file,"src/lib/wf_render_elements.erl"},{line,115}]},
 {wf_render_elements,render_elements,2,
                     [{file,"src/lib/wf_render_elements.erl"},{line,37}]},
 {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
 {wf_render_elements,render_elements,2,
                     [{file,"src/lib/wf_render_elements.erl"},{line,32}]},
 {wf_render_elements,call_element_render,3,
                     [{file,"src/lib/wf_render_elements.erl"},{line,131}]}]

Jesse Gumm

unread,
May 8, 2015, 10:56:21 AM5/8/15
to nitrogenweb

Hi Bernie,

To just check the basics first, is sync started (started with "sync:go()" in the erlang shell), and giving the notification that the file was recompiled, or are you running 'make' and restarting the erlang vm after changing the file?  When in doubt, shutting down the VM and running 'make' is always the "nuke it from orbit, it's the only way to be sure" approach.

The {error, nofile} seems to imply that the template file was not found, which leads me to believe your change of path is not being recompiled.

-Jesse

--
You received this message because you are subscribed to the Google Groups "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb...@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at http://groups.google.com/group/nitrogenweb.
For more options, visit https://groups.google.com/d/optout.

Bernie

unread,
May 8, 2015, 1:13:57 PM5/8/15
to nitro...@googlegroups.com
Thanks for the quick reply, Jesse!

I was indeed using sync:go() and now tried make and restart, but the error is still there.

When I changed the file path back to wrong file="./templates/demos46.html" the error message changes to:
throw:{template_not_found,"./templates/demos46.html"}

So it seem to pick up on the template at some level. I did notice that the stack trace references "src/elements/layout/element_template.erl" but the "nitrogen/site/src/elements" directory is empty while there is a "nitrogen/lib/nitrogen_core/src/elements/layout/element_template.erl" file.
Does this mean anything?

Jesse Gumm

unread,
May 8, 2015, 1:47:17 PM5/8/15
to nitrogenweb

Thanks for the followup. Oh, I think I see what it's doing. It looks like during the evaluation of the template, there is a call to a module that doesn't exist within the template.  That's supposed to fail silently, but perhaps I could make it generate a warning. If you're feeling adventurous, trying editing lib/nitrogen_core/src/elements/layout/element_template.erl on line 172 and remove the left-hand-side of that call - the call to ensure_loaded. Just remove the "{module, Module1} ="

Removing that *should*  cause the call to that unknown module to fail silently, allowing the rest of the template to carry on its duties.

-Jesse

Bernie

unread,
May 8, 2015, 2:41:03 PM5/8/15
to nitro...@googlegroups.com
Hmm, maybe I did it wrong. In element_template.erl:

        % If the function in exported, then call it.
        % Otherwise return undefined...
        code:ensure_loaded(Module1),         % line 172
        case erlang:function_exported(Module1, Function, length(Args)) of
            true -> _Elements = erlang:apply(Module1, Function, Args);
            false -> undefined
        end

gave me:

error:undef
--------------------------
[{linecount,render,[],[]},
 {demos_wizard,left,0,
               [{file,"/home/bernie/work/test/erlang/nitrogen/nitrogen/site/src/demos/demos_wizard.erl"},
                {line,24}]},

 {element_function,call_next_function,1,
                   [{file,"src/elements/other/element_function.erl"},
                    {line,35}]},
 {wf_render_elements,call_element_render,3,
                     [{file,"src/lib/wf_render_elements.erl"},{line,130}]},
 {wf_render_elements,render_element,1,
                     [{file,"src/lib/wf_render_elements.erl"},{line,115}]},
 {wf_render_elements,render_elements,2,
                     [{file,"src/lib/wf_render_elements.erl"},{line,37}]},
 {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
 {wf_render_elements,render_elements,2,
                     [{file,"src/lib/wf_render_elements.erl"},{line,32}]}]

I guess that's cause it matches false -> undefined because Module1 did not load?
Just to try, I took out left() in demos_wizard.erl and there is no more error, but the page looks messed up.

Jesse Gumm

unread,
May 8, 2015, 2:51:04 PM5/8/15
to nitrogenweb

Perfect, that worked as expected. The template is loaded, and now it's crashing just in the page module on the line specified, you don't need the linecount module call, you can remove it altogether.

Bernie

unread,
May 8, 2015, 3:08:00 PM5/8/15
to nitro...@googlegroups.com
Got it. I can keep left() and just delete linecount:render() leaving the page structure intact.

Thanks a lot for your help Jesse! And since I already got your attention, are you by any chance still working on that nitrogen book?

Jesse Gumm

unread,
May 8, 2015, 3:10:29 PM5/8/15
to nitrogenweb

Great!

Yes, I am indeed, and we're trying to get a new version out. We meant to get a new version out last week, but alas, one section has me hemming and having about this best to present some material.

But we're almost ready to put out a new version with a handful of new chapters.

Thanks for asking. I will post to the group again once the new version is posted.

-Jesse

Reply all
Reply to author
Forward
0 new messages