Login  Register

Re: NAML Feedback

Posted by DavidJCobb on Mar 28, 2012; 9:50pm
URL: https://support.nabble.com/NAML-Feedback-tp7377071p7415604.html

Hugo <Nabble> wrote
Great feedback. As you realized, our code throws a NullPointerException when a "null" value is printed together with other information in the output stream (in your case, it was printed together with line breaks). This exception has an important role in the code because it brings bugs to the attention of the developer (you don't want nulls to be printed when NAML is building a page, for example). But your case is different and the exception becomes indeed a problem. So we have created a new command called "null_exception_to_null" that catches the NullPointerException and prints a single "null" to the stream. Here is some code that works:
<macro name="test">
	<n.safe_default to="No bug" text="[n.crlf/][n.null/]"/>
</macro>

<macro name="safe_default" parameters="to,text" >
	<n.default to="[n.to/]" text="[n.null_exception_to_null.text/]"/>
</macro>
The name of this new command is a bit strange, but we couldn't find anything better (suggestions?). It should solve your problem though.
Name seems fine to me. Thanks for the new command; it should prove useful. :)

Hugo <Nabble> wrote
You can introduce new tags with the "static" tag, just like this:
<static>
  thead
  tfoot
</static>
Each line represents a new tag that you want to use.
Good to know.

Hugo <Nabble> wrote
This is possible, but we need a way to select arbitrary nodes in the database and retrieve them as a list. We believe the solution is to use our tag table, which is pretty much like a label that is applied to a node or user (think of labels in Gmail). So somehow you would stick a label in some nodes and then use a filter to retrieve them. Would this solve your problem?
That could work for persistent storage, and could help to solve the issue, yes.

I don't know much about databases, but that does sound like it could be hard to keep efficient -- retrieving the nodes would require looping through every node on the site, no? I think a simpler solution might be to add a function that'll take a comma-delimited list of IDs as a string, and return a nodelist that could then be sorted. Given a safe storage area for the comma-separated list (i.e. as a property on the root_node), I think this would accomplish the same thing as a tag table, but with the benefit of being able to grab nodes directly by ID rather than having to check all of them for a property.

Either way'll get the job done. I propose the alternative simply because I think it could have a performance advantage, though I've no clue how large the difference would be.

Hugo <Nabble> wrote
DavidJCobb wrote

QUESTION about translations

That's correct, "T" tags are used for translations. Basically, if you wrap a string with <t>...</t> tags, you tell the code that a replacement for that text may be available. Here is an example: imagine a macro that has this text:
... <t>some text</t>...
If no translation is available, this is not a problem at all. The code will simply use the text between the T tags. But you may override that code with:
<translation><from>some text</from><to>SoMe TeXt</to></translation>
you can even override the translation with:
<override_translation><from>some text</from><to>s-o-m-e t-e-x-t</to></override_translation>
This is nice because Nabble has some ready-to-use translations, but you can use the last case above to customize it even more.
So if I were to find some people who spoke other languages, I could actually start packing some basic translations with the NAML code for the features... Very interesting. Thanks for the info.

Hugo <Nabble> wrote
DavidJCobb wrote

SUGGESTION: Reading cookies from NAML

We just added a new command called "get_cookie_value", which can be used like this:
<n.get_cookie_value name="mycookie"/>
Much appreciated. :)

Hugo <Nabble> wrote
DavidJCobb wrote

PROBLEM: Error pages don't escape tags

I was not able to reproduce this. Please let me know if you have a URL or some steps to reproduce it.
I'll try to remember to post here next time I cause an Error 500.

Hugo <Nabble> wrote
DavidJCobb wrote

SUGGESTION: Control over unhandled exception output

I am investigating this and will come with a solution soon.
Thanks for looking into it.

Hugo <Nabble> wrote
DavidJCobb wrote
Is this filter syntax stable/frozen, or is it an internal thing subject to frequent change? (IOW is it safe to use?)
This is stable. Actually, this is a SQL condition that will be applied to the main SQL when retrieving nodes from the database. So the syntax is certainly stable. Ideally we should create more and more filters that anyone can use, but custom filters like that should work fine.
Perfect! One of our UI tweaks takes advantage of that, so it's good to know that we can rely on it when we need it.