|
From: Keats <ke...@su...> - 2003-08-01 15:35:20
|
You're absolutely write and we've agonized over this on and off for years. But no really great solutions have been put forward.
I have suggested a directive, like #trim that could do things like trim all leading whitespace, trim all trailing whitespace, trim all leading and trailing whitespace, trim a fixed amount of leading whitespace, etc.
Nobody seemed very excited about this. Maybe your Ignition framework will renew interest in this.
Another idea I had was to specifiy a "leader" char, like a dot leader which would be eaten from the begining of each line.
Any of these sound useful to you?
Keats
-------Original Message-------
From: Marc Palmer <ma...@an...>
Sent: 08/01/03 11:05 AM
To: ke...@ea..., web...@li...
Subject: Re: [Webmacro-devel] Whitespace :(
>
> On Fri, 1 Aug 2003 10:19:10 -0400 (GMT), Keats <ke...@su...> wrote:
> Marc,
>
> It's really not as bad as you're making it out to be. The only known
> bugs with whitespace handling are the implicit #begin and #end problems.
> You can avoid this altogether by using curly braces when you need
precise
> control of whitespace.
>
> The rules are a bit complex, but they were hashed out exhaustively and
> there is some logic behind them.
>
> If you have a specific case that's giving you trouble I'd be glad to
take
> a look.
Thanks, that's very kind. My point is though that this shouldn't be
necessary!
The trouble is that the templates have to end up looking really ugly (for
plain text formatted output), and most people who are not hardcore WM
users
will get extremely confused by the (I'm sure very logical) rules used and
how they have to position things to get their results.
I'm just wondering if there's some other way to approach this. For example
I've written a pretty next text formatting helper to reduce these problems
-
but it requires calls $textHelper.write( string) for everything if you
want it to work.
Here's an example of that template I showed before, which now produces
reasonable output - although I would like an indent on every field line of
the SQL output:
#macro SQLType( $field)
#set $class = $field.ConstraintProperty.ClassName
#if ($class == "java.lang.String") #begin
VARCHAR($field.ConstraintProperty.MaxLength) #end
#elseif ($class == "java.util.Date") #begin DATE #end
#else #begin $field.DataType.Name #end
#end
<h2>Generator for SQL CREATE TABLE based on Metalizer Schema</h2>
<h3>SQL follows:</h3>
#set $schema = $Ignition.getSchema($Ignition.FieldValue.schemaName)
<pre>
CREATE TABLE tablename (
#set $first = true
#foreach $group in $schema.FieldGroups
#begin
#foreach $fieldName in $schema.getFieldNamesInGroup($group)
#begin
#if (!$first) #begin ,
#end
#set $field = $schema.getField($fieldName)
$field.Name #SQLType($field) #if ($field.ConstraintProperty.Required)
#begin NOT NULL #end #set $first = false #end
#end
);
</pre>
There are all kinds of hacks required - blocks all on one line which are
very nasty for long lines, #end(s) at the beginning of the next line
instead of indented properly so you don't get the extra spaces included
and
so on.
I really do appreciate the complexity and intentions behind the current
scheme. In theory, if you want everything to be on one line you should
have
one long line of code. You -can- get around the nastiness of that by
avoiding directives on the line, having set their results into variables
before rendering the line and so on.
I know that there are contradictions too... in one sense we don't want WS
to be eaten, so output placement is predictable, but at the same time we
want to be able to indent code to produce readable source.
I just think... there has to be a better way, especially as we are
promoting WM as something that is not just for HTML.
If I had to hand a WM app to somebody for them to write plain text
templates (say for emails) I would be nuts - $xxx and #if are one thing to
explain, precise positioning rules are another.
$0.02
--
Marc Palmer
Contract Java Consultant/Developer
w a n g j a m m e r s
java and web software design
experts with an ethical outlook
http://www.wangjammers.org
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio
.NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Webmacro-devel mailing list
Web...@li...
https://lists.sourceforge.net/lists/listinfo/webmacro-devel
>
|