moovweb / tritium

Tritium is a magical document modifying language. It's JavaScript-like and simple to learn. Think XSLT without the nightmare. It was designed by Hampton Catlin (@hcatlin), and has been heavily influenced by Aaron Leung (@akhleung).
http://tritium.io
Mozilla Public License 2.0
33 stars 7 forks source link

Opening scope after local variable assignment #30

Closed bkendzior closed 11 years ago

bkendzior commented 11 years ago
%search_link = "http://search.pontofrio.com.br/search?w=" {
  rewrite("link")
}

Throws the following error:

Nov.19.11.02-aI : Error: Invalid instruction. Should have stopped before linking!
FUNCTION_CALL rewrite

Tritium Stack
=========

/Users/brian/workspace/pontofriotablet/scripts/main.ts:41
/Users/brian/workspace/pontofriotablet/scripts/main.ts:40
/Users/brian/workspace/pontofriotablet/scripts/main.ts:38
/Users/brian/workspace/pontofriotablet/scripts/main.ts:37
/Users/brian/workspace/pontofriotablet/scripts/main.ts:35
/Users/brian/workspace/pontofriotablet/scripts/main.ts:3
/Users/brian/workspace/pontofriotablet/scripts/main.ts:4
/Users/brian/workspace/pontofriotablet/scripts/main.ts:1

Changing to a global variable resolves this issue, as does opening the scope directly on the variable after assignment:

%search_link = "http://search.pontofrio.com.br/search?w=" 

%search_link {
  rewrite("link")
}
$search_link = "http://search.pontofrio.com.br/search?w=" {
  rewrite("link")
}
mdayaram commented 11 years ago

Assigning to Mr. Leung!

tdesikan commented 11 years ago

i thought rewrite("link") was deprecated. no?

On Mon, Nov 19, 2012 at 11:12 AM, Manoj Dayaram notifications@github.comwrote:

Assigning to Mr. Leung!

— Reply to this email directly or view it on GitHubhttps://github.com/moovweb/tritium/issues/30#issuecomment-10526543.

Tarun Desikan moovweb.com http://beta.moovweb.com

tarun@moovweb.com 646-731-9750

akhleung commented 11 years ago

Signals a link-time error now with an informative error message.