Adding html to text=

13 views
Skip to first unread message

Wes James

unread,
Oct 7, 2016, 12:19:47 AM10/7/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
I'm playing with the nitrogen elements demo.  In there it has:

#tab{title = "tab-title", body = ["test"]
            }

I'd live to add a div in the title so I can change a numeric value that will be there.  How would I do that.  When I put a <div></div> in tite="", it just shows that <div> text in the tab title.

Thx.

Stuart Thackray

unread,
Oct 7, 2016, 2:33:19 AM10/7/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
not sure of the element #tab{}

but  according to the definition of title it is
        title=""                :: undefined | text(),

I would suggest if you wanted to change the value of title to just wf:replace(<ID>, <NewELEMENT>).

Sure there is also a javascript way what you want so you could use wf:wire(..) to achieve it also.

Kevin Montuori

unread,
Oct 7, 2016, 9:24:35 AM10/7/16
to Wes James, Nitrogen Project / The Nitrogen Web Framework for Erlang
>>>>> "wj" == Wes James <comp...@gmail.com> writes:

wj> I'm playing with the nitrogen elements demo. In there it has:
wj> #tab{title = "tab-title", body = ["test"]}

wj> I'd live to add a div in the title so I can change a numeric
wj> value that will be there. How would I do that.

Try something like

#tab{body=#panel{ id=xxx, text="test" }}.

#span{} will work in place of #panel{} too.


k.


--
Kevin Montuori
mont...@gmail.com

Wes James

unread,
Oct 7, 2016, 12:35:52 PM10/7/16
to Kevin Montuori, Nitrogen Project / The Nitrogen Web Framework for Erlang
If you leave the text= out, it shows "No Title" in the tab at the top.  Whatever you put in the body= goes in the lower main part of the tab box.

-wes

Jesse Gumm

unread,
Oct 7, 2016, 1:25:59 PM10/7/16
to nitrogenweb

Hi Wes,

This means that the #tab element in the nitrogen_elements project is overloading what the title element is really *meant* to be.

Which is fine. You'll just need to edit that element's render_element function and make sure that title either isn't placed into a "text" attribute or run through the wf:encode_html function.

You'll be able to find that code in lib/nitrogen_elements.

I'd recommend forking that project yourself  on github to and either submitting a pull request to the main repo or simply maintaining your own fork of nitrogen_elements, which is, after all, a community driven project rather than an official part of Nitrogen.

Please let me know if this advice is unclear or if you get stuck further.

All the best,

-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+unsubscribe@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at https://groups.google.com/group/nitrogenweb.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages