BrailComplex Expressions
The technical details are going to be of interest to a limited number of people, but it comes down to a design choice that I made when I first wrote Brail. It has to do with how the text is outputted into the compiler, and some tricky bits that can happen there because Boo's compiler understand that "this is ${code}" and can turn it into the correct string, based on the value of the variable "code".
That was fine until I realized that I can do more than a simple variable substitution in there. You can call anything that returns a value, which is very valuable for code such as:
The problem started when the code inside the expression got even more complicated. No longer a single method call, but method calls that wanted to pass string parameters (with " in the middle), or maybe they wanted to use inline expressions as well. I always work-around those issues, but today I got a piece of code that was too pretty to give up on, so I fixed the Brail pre-parser (thrice, until I got it right) so it would output the correct code to the compiler.
What this basically boils down to is that this is now valid code:
${Html.LinkToAttributed( title ,@customers, @list, {
@onclick: "paginate(${pageIndex});"
}
)}
If you are interested, the output of this is:
<
a href="/customers/list.rails" onclick="paginate(5);">first </a>I like it.
More posts in "Brail" series:
- (14 Jul 2007) Null propagation
- (30 Jun 2007) DSL Support Information
- (06 Apr 2007) Complex Expressions
Comments
Hey Ayende,
Just grabbed the latest bits and I may have found another edge case for ya (or perhaps there is another workaround). Basically this was working before...
-- index.brail --
<?brail OutputSubView('/common/defaultFocus', { 'controlIdToFocus':"${division.Name}" }) ?>
-- /common/defaultFocus.brail --
<script type="text/javascript"> Event.observe(window, 'load', function() { ${controlIdToFocus}.focus(); }); </script>And it seems the latest bits breaks this and I suspect it has to do with the changes in expression handling...
I've tried a few variations... Any ideas or workarounds?
Thanks!
Looks like a bug indeed.
Can you send me the full exception stack (in email) and the view?
Comment preview