velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Chassande-Barrioz <sebastien.chassa...@inrialpes.fr>
Subject indentation of templates
Date Mon, 11 Mar 2002 18:22:32 GMT
Hi,

I am new user of the velocity product since few days. I very happy of 
the simplicity to use it and its capacities. I noticed with my small 
experience of velocity (4 full days) that the "code" of my templates is 
not very readable. For example it is impossible to indent a macro 
because the spaces or the tabulations are generated.
Belove you can find one of my velocimacro which is not really readable 
by another person except the author (...me) without efforts. Indeed this 
macro contains several control structures (#if #foreach).
I think that one of the aims of the velocity product is to simplify the 
generation and to make reachable (readable) the generator, therefore the 
templates, by other people than the author.

Do you have advices to make more readable a template ?
Otherwise, this aspect is it in your todo list ?

best regards,
Seb
-- 
Chassande-Barrioz Sebastien
INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
Mail job : sebastien.chassande@inrialpes.fr
Phone : 04.76.61.55.16

----------------------------------------------------------------
#############################
## MACRO writetGenClassDef ##
#############################
#macro(writetGenClassDef $gcr $fieldName $level)
#set($nd = $gcr.getRefNameDef($cparam.getMapperName(), 
$cparam.getMappingName()))
#set($arraySize = ($nd.getFieldRefNumber() + $nd.getHiddenFieldNumber()))
		fds = new FieldDesc[$arraySize];
#set($gcVarName = "${fieldName}GCM${mappingTools.getGenclass($level)}")
#set($i=0)
#foreach($ndField in $nd.iterateField())
#if ($tools.isFieldName($ndField))
#set($realField=$class.getTypedElement($ndField.getField()))
#else
#set($realField=$ndField)
#end ##else
#writeFieldDescFilling($realField "fds[$i]")
#set($i=($i+1))
#end ##foreach
		((GenClassProp) $gcVarName ).setIdentifierDesc(fds);
##
## write the initialization of each field of the index of the genclass
##
#set($gc = $gcr.getGenClass())
		fds = new FieldDesc[${mappingTools.getIndexNumber($gc)}];
#set($i=0)
#foreach($indexField in $gc.iterateIndexField())
#writeFieldDescFilling($indexField "fds[$i]")
#set($i=($i+1))
#end ##foreach
		((GenClassProp) $gcVarName ).setIndexDesc(fds);
##
##write element
##
#if($gcr.isPrimitive())
		fds = new FieldDesc[1];
#writeFieldDescFilling($gcr.getPrimitiveElement() "fds[0]")
#elseif ($gcr.isClassRef() || $gcr.isGenClassRef())
#set($elemNd=$gcr.getClassRef().getNameDef($cparam.getMapperName(), 
$cparam.getMappingName()))
#set($i=1)
#set($size=${elemNd.getHiddenFieldNumber()}+1)
		fds = new FieldDesc[$size];
#writeCreateFieldDescRefTop("fds[0]")
#foreach($elemField in $elemNd.iterateField())
#writeFieldDescFilling($elemField "fds[$i]")
#set($i=($i+1))
#end
#end ##test element type
		((GenClassProp) $gcVarName).setElemDesc(fds);
#writeInitGenClassMapping($gcr $gcVarName $level $fieldName)
#if($level==0)
#set($g='"')
#set($return1= "{$g${gcr.getGenClassName()}$g")
#else
#set($return1="$return1, $g${gcr.getGenClassName()}$g")
#end
#if($gcr.isGenClassRef())
#set($level=($level+1))
#writetGenClassDef( 
$gcr $fieldName $level)
#else
#set($return1 = "${return1}}")
#if($gcr.isClassRef())
#set($return2=$gcr.getClassRef().getMOClass())
#elseif ($gcr.isPrimitive())
#set($return2=$gcr.getPrimitiveElement())
#end
#end
#end
##
##


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message