Illudium and CFML templating
Kyle Hayes just pointed out that Brian Rinaldi has just added CFML support for templating in his Illudium generator. It will be interesting to see if this feature ends up being used - I certainly think it is a great idea and am glad Brian took the time to give this a try.
On a connected note, Brian uses <% for his generation time tags, and I think I like that better than the < < in CF template, so I'm going to change the default characters in CF template to Brians syntax - thanks Brian!



@Terrence, well if you like it you could always include CF Template (or just the idea like Brian did) in Squidhead!
Not in the slightest. Please everyone check out the presentation by Brian - it should be great!
I like the << as it is quicker to type. Of course, it just takes getting used to the other way, but I was wondering if the reasoning is because Ruby on Rails, JSPs, and others have gone the <% way?
If so, if you tried to use this in those environments, would that potentially cause any trouble?
Any suggestions? << and >> works well for tags. What about variables? Right now I'm using %, but that requires you to escape all percentages, so <% would have to be written as <%% which is no fun. Any thoughts? Don't want to use $ as that'd make PHP hard, deployment languages would be CF, Ruby, and possibly PHP, C# with ASP.NET and/or Java. I *might* have to go to a 2 character variable token.
Any thoughts or inputs appreciated!
Of course, no biggie for CF only, but am trying to have something more general for my own use. Big issue I have is what token to use for variables now. I am using % which works fine until you start generating ASP.NET but then it is a pain. Any thoughts?
But if they are allowed to use target language constructs, that is when it gets tricky I would think.
(Off the top of my head, as often is the case)
Simple example, can't use <> for tags as used by cf. <<>> works fine.
Can't use #VarName# or $VarName for vars as used by CF and PHP respectively. Trying to figure out what to use. % was OK for CF, but I don't think it'll work out for ASP.NET (it would, but only if they escaped the token in the ASP.NET code which makes that code less readable).
My backup is a dual token - something like %%, but I'd rather have a single character that just isn't used very often as a token in templating or scripting languages but that is still fairly easy to find on a keyboard. Any thoughts?
But I was thinking if the generator is in CF, then you should be able to take %varName% and convert it at generation time to the specific platform. That is what I meant when I thought there may be no issue.
Given what you just said, I'm having trouble finding it now.
<cfquery name="GetUser">
SELECT FirstName,LastName
FROM tbl_User
WHERE UserID = #form.UserID#
</cfquery>
I might have gen time variables to generate this for each business object, so I might have a template like:
<cfquery name="Get%ObjectName%">
SELECT %PropertyNameList%
FROM %TableName%
WHERE %IDPropertyName% = #form.%IDPropertyName%#
</cfquery>
Workflow of CF Template:
Transform %% (escaped %) into unique string so don't process it
Transform << >> and % into unique strings
Transform < > and # into something innocuous
Transform whatever I turned << >> and % into < > and #
Save to file, and process
Turn whatever I turned < > and # into back into those.
Turn whatever I turned %% into back into a single %
This works fine for CF, but if I had a token in the target language, I'd have to escape it everywhere so <% form.UserID %> would have to be <%% form.UserID %%> otherwise it'd turn the % into #, process it and get a generation time error. Escaping token in target language would be harder for developers to read, so I'm looking for a token for my generation time variables that is seldom found as a token or as part of a token in the target language.
Make sense?
I was thinking more generic, where you have your own templating language that would convert to any language. I guess I let my imagination go wild. =)
Point taken.
In that case, what about surrounding with colons? Ruby uses the colon to denote a symbol type, but you could use regex like :\w(\w\d)*: ... that may need some work, of course. I think $ should work like that as well, but either could make things hard to read if you were using the target language that has those tokens.
This is getting difficult. What about a high-valued ascii character? ยท is my favorite (250) It might be bad at first, but its something you can easily learn, and its only one of them. Of course, using double whatever's may work better.
I don't love high value ASCII - anything I can't immediately see on any keyboard on any computer in any language set is a little more esoteric than I want to do. That only leaves so many options. I like wider characters like % or # or even $ as it is easier to read. Maybe ~ would be an option, although I don't love it visually - you don't usually see many tildas in code (in languages I've looked at - anyway). I suppose a ? has a certain logic to it - ?Value? replaces the string with the (currently unknown) value - I might be able to get into that although it seems a little strange at first. There are many tokens I might be able to use with some smart regexs, but I would want to think them through very carefully. Double characters are acceptable but a little unwieldy (maybe the least bad alternative).
Any more thoughts?
I'm so used to using alt-250 (on the keypad) that I can type it pretty much in stream (at least as quickly as I can think about what needs to come next). But, I realize the learning curve needs to be relatively low for things to be useful to the masses. Not even the best among us will fight /against/ something for too long before we determine its not worth it and move on to something else.