Was wondering how can i create a hash & store those (matches) list value in that? For each key -> 2 values(rev) Then call those key value pair.. Unable to do such thing..what do u suggest Josh?
Badly stuck since 3days working on this. Now i really doubt on my skills. Hope i get where i m going wrong.. On Thu, Apr 16, 2009 at 4:00 PM, Kapila Kohli <[email protected]>wrote: > (adding support group also) > > >> Hi Josh, >> Thanks for your reply. >> As you mentioned abt the format, its corrected now. >> So far code is:- >> <code> >> [% count = 0 %] >> [% increment = 1 %] >> [% currentRepo ="http://svn/cvsweb/cvsweb.cgi" %] >> [%- text= wrapped_comment FILTER quoteUrls(bug.bug_id) -%] >> [% IF (matches = >> text.match('([\w./\-|\_|\.]+)[\s|\n]+([\d.]+|NONE)[\s|\n]+([\d.]+|NONE)[\s|\n]*',1)) >> %] >> [% FOREACH match = matches %] >> [% text= text.replace("match.$count",'<a >> href="$currentRepo/match.$count">match.$count</a> <a >> href="$currentRepo/match.$count?rev=match.$count+1">match.$count+1</a> <a >> href="$currentRepo/match.$count?rev=match.$count+1">match.$count+1</a> ' ) >> %] >> [% END %] >> [% count = count + increment %] >> [% END %] >> [%- text -%] >> >> </code> >> To print the list value - tried [% value = match.$count %];[% >> match.join(';')%] >> Its o/p is > ;filename1;ver1;ver2;filename2;rev1;rev2 >> >> quoteUrls() is the module which is for formating & mail sending.Format the >> text(wrapped_comment) i.e the file names etc. Not much to be worried about. >> >> If i print the [%- match -%],[% match.join(',')%] >> then o/p it gives = >> >> orion/WEB-INF/src/com/mmt/hotels/seo/templates/CityPageTemplate.xml,orion/WEB-INF/src/com/mmt/hotels/seo/templates/CityPageTemplate.xml1.1.2.1,1.1.2.11.1.2.2,1.1.2.2 >> >> means doesn't take each field in one variable to acheive this- [%- value= >> match -%],[% match.join(',')%] >> o/p >> -,orion/WEB-INF/src/com/mmt/hotels/seo/templates/CityPageTemplate.xml,1.1.2.1,1.1.2.2 >> >> unable to understand this behaviour. >> How can i have each list value retreived in 1 variable. That variable >> should get incremeneted & added in the text.replace(href) >> >> I am unable to parse the value in text.replace function. i.e in >> text.replace("match.$count",'<a >> href="$currentRepo/match.$count">match.$count</a> >> >> "match.$count"- how to parse that it matches that value & then replace >> </pre> >> > > >> If [% currentRepo ='http://svn/cvsweb/cvsweb.cgi' %] > > call [% text.replace('CVS','<a href="$currentRepo">NEXT</a>' ) %] > then y is the NEXT Link not linked to the value set. > >> >> What do you suggest where i ma going wrong? Have read the link u sent it >> many times. Highly confused with this entangle some silly mistakes i making >> me round-about. Please suggest. >> >> >> On Wed, Apr 15, 2009 at 10:46 PM, Josh Rosenbaum <[email protected]>wrote: >> >>> Kapila Kohli wrote: >>> >>>> I have so far gathered a code- >>>> >>>> <pre[% ' id="comment_text_' _ count _ '"' IF mode == "edit" %]> >>>> [% count = 0 %] >>>> [% increment = 1 %] >>>> [%- text= wrapped_comment FILTER quoteUrls(bug.bug_id) -%] >>>> >>>> [% IF (matches = >>>> text.match('([\w./]+)[\s|\n]+([\d.]+|NONE)[\s|\n]+([\d.]+|NONE)')) %] >>>> [% FOREACH match = matches %] >>>> [%- text= text.replace('match.\$count','<a href=" >>>> http://svn/cvsweb/cvsweb.cgi">abc</a>') -%] >>>> [% END %] >>>> [% count = count + increment %] >>>> [% END %] >>>> [%- text -%] >>>> >>>> But still not able to get the right code replace i.e in match regex. >>>> Can anyone suggest where i am going wrong. >>>> >>> >>> Ok, I missed this one. Making good progress. :) What's the quoteURLs >>> filter do? Have you checked what kind of output it provides? >>> >>> text.match() will only return an array of the parenthesis values for a >>> single match, unless you provide it with a 1 value for the global parameter. >>> ie: text.match('regexp', 1). So you'll probably want to do that, since that >>> appears to be how you are using it in your code. >>> >>> The documentation shows that: >>> http://template-toolkit.org/docs/manual/VMethods.html#method_match >>> >>> I just tested your regexp with your original string and it works fine. >>> (Although it doesn't include the dash as you probably want: [\w./\-]+ >>> instead of [\w./]+) So I'm guessing the quoteUrls filter is doing something. >>> >>> -- Josh >>> >> >> >
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
