cb_admin icon indicating copy to clipboard operation
cb_admin copied to clipboard

added missing var 'timestamp' for template render

Open fscz opened this issue 12 years ago • 3 comments

fscz avatar Feb 18 '13 00:02 fscz

Please exclude the changes from boss.config and I will merge this in.

evanmiller avatar Feb 18 '13 02:02 evanmiller

Hi Evan,

Opening https://localhost:8001/admin/lang/show

on my admin interface, I receive this error:

Error: {undefined_variable,[{name,original_lang}, {file,"src/view/admin/layouts/admin.html"},

{line,{30,70}}]}

My last bug fix concerned a similar error, only in this case, I'm unsure, how to fix it. But what confuses me more….

I have two machines, both running OSX 10.8, both running cb/head, cb_admin/head. Both machines run erlang R15B03 (erts-5.9.3.1). One machine gives me the error, the other does not.

The error right now points to

src/view/lang/show.html

function startTranslation(span) {
var span_id = span.id;
var textbox = document.getElementById("trans_"+span_id);
if (textbox && textbox.value == "" && span.firstChild.value != unde
fined) {
google.language.translate(span.firstChild.value, "{{ original_lang }}", "{{ this_lang }}", function(result) {
if (!result.error) {
if (result.translation) {
textbox.value = result.translation;

}

where {{ original_lang }} isn't set. I could use something like

OriginalLang = boss_env:get_env(assume_locale, "en"),

and add it to the template.

But I think the general question is, how to deal with templates, that are used by different requests. Shouldn't left-out variables just be ignored?

Regargds, Fabian

On Feb 18, 2013, at 3:26 AM, Evan Miller [email protected] wrote:

Please exclude the changes from boss.config and I will merge this in.

— Reply to this email directly or view it on GitHub.

fscz avatar Feb 18 '13 19:02 fscz

The error is a new one recently introduced into ErlyDTL; it's possible that one machine is running an older ErlyDTL.

In general you should surround possibly-undefined variables in an if-statement like:

{% if orig_lang %}{{ orig_lang }}{% endif %}

Or use the "default_if_none" filter:

{{ orig_lang|default_if_none:"" }}

evanmiller avatar Feb 18 '13 19:02 evanmiller