#8 Multiple Dynamic Block - DelVar ClearBlock & a small bugfix.

open
nobody
None
5
2014-08-14
2010-04-12
Anonymous
No

I have a problem I would love if you could improve so we can use nested blocks.

I have somthing like this :

t.UpdateBlock "cat_menu_block"
t.SetVariable "block-cat-menu", "SomeMenu"

t.UpdateBlock "cat_item_block"
t.SetVariable "block-cat-link", "SomeLink"
t.SetVariable "block-cat-name", "SomeName"
t.ParseBlock "cat_item_block"

t.ParseBlock "cat_menu_block"
t.UpdateBlock "cat_menu_block"
t.SetVariable "block-cat-menu", "SomeOtherMenu"

t.UpdateBlock "cat_item_block"
t.SetVariable "block-cat-link", "SomeOtherLink"
t.SetVariable "block-cat-name", "SomeOtherName"
t.ParseBlock "cat_item_block"
t.ParseBlock "cat_menu_block"

and the template is :

<!-- BEGIN cat_menu_block -->
<li>
<p>
{{block-cat-menu}}
</p>
<ul>
<!-- BEGIN cat_item_block -->
<li><a href="{{block-cat-link}}">{{block-cat-name}}</a></li>
<!-- END cat_item_block -->
</ul>
</li>
<!-- END cat_menu_block -->

Really appreciate it!!

one more thing, I added 2 simple functions that come it handy for me :

public sub DelVariable(s)
if p_variables_list.Exists(s) then
p_variables_list.Remove s
end if
end sub

and

public sub ClearBlock(inBlockName)
p_template = p_regexp.Replace(p_template, "__" & inBlockName & "__")
end sub

last but not least :

on one of your reg pattern : p_regexp.Pattern = "(" & p_var_tag_o & ")([^}]+)" & p_var_tag_c
on GetOutput function, i think (im not sure tho) the [^}] is about getting lazy reg_exp, but if p_var_tag_c is changed, a bug will show up.

I think the correct form will be : ")([^" & left(p_var_tag_c, 0) & "]+)" & p_var_tag_c

not sure about left function either, i don't know much about ASP.

hope it helps!

please notify me via email if you read this and your comments/opinions... I don't go around much.

Greetings,
Bart.

p.s.: in the asptemplate.asp, remember to update version
'ASP Template 1.2.1 to SP Template 1.3.1

Discussion