Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing var 'timestamp' for template render #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

added missing var 'timestamp' for template render #18

wants to merge 1 commit into from

Conversation

fscz
Copy link

@fscz fscz commented Feb 18, 2013

No description provided.

@evanmiller
Copy link
Contributor

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

@fscz
Copy link
Author

fscz commented Feb 18, 2013

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.

@evanmiller
Copy link
Contributor

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:"" }}

@ghost ghost assigned zkessin Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants