zoukankan      html  css  js  c++  java
  • 通过静态模版动态生成静态列表的实例子(原创)

    原创

    <%
    dim str
    str=""
    str=str&"sasdsadasd{list:loopnum=5,pid=美女图文1}<table width=400 border=1 align=center cellpadding=1 cellspacing=1><tr>"
    str=str&"<td width=200 height=20 class=f12px>·<a href={$Path} target=_blank>{$ShowHead}</a></td>"
    str=str&"<td width=200>{$AddTime[yyyy-MM-dd]}</td></tr></table>{/list}怎么不出来卡s"
    str=str&"{list:loopnum=3,pid=美女图文2}<table width=400 border=1 align=center cellpadding=1 cellspacing=1><tr>"
    str=str&"<td width=200 height=20 class=f12px>·<a href={$Path} target=_blank>{$ShowHead}</a></td>"
    str=str&"<td width=200>{$AddTime[yyyy-MM-dd]}</td></tr></table>{/list}asdsd"
    str=str&"{list:loopnum=3,pid=美女图文3}<table width=400 border=1 align=center cellpadding=1 cellspacing=1><tr>"
    str=str&"<td width=200 height=20 class=f12px>·<a href={$Path} target=_blank>{$ShowHead}</a></td>"
    str=str&"<td width=200>{$AddTime[yyyy-MM-dd]}</td></tr></table>{/list}怎么不出来卡s"

    while instr(1,str,"{list:")>0
    hanshu1=loopnums(str)
    hanshi2=pids(str)
    hanshu1=clng(hanshu1)
    html5=""
    for i=1 to hanshu1
    html2=htmls(str)
    html2=replace(html2,"{$Path}",i)
    html2=replace(html2,"{$ShowHead}",hanshi2&i)
    html2=replace(html2,"{$AddTime[yyyy-MM-dd]}",now())
    html5=html5&html2

    next
    str2=mbstr(str)
    str=replace(str,str2,html5)
    wend
    response.Write(str)
    '获取参数1
    function loopnums(str)
    tem1=1
       tem2=instr(tem1,str,"loopnum")
       tem3=instr(tem1,str,"}")
      str2=mid(str,tem2,tem3-tem2)
     str2=replace(str2,"loopnum","")
     str2=replace(str2,"pid","")
     str2=replace(str2,"=","")
     str3=split(str2,",")
     loopnums=str3(0)
      end function
    '获取参数2
    function pids(str)
    tem1=1
       tem2=instr(tem1,str,"loopnum")
       tem3=instr(tem1,str,"}")
      str2=mid(str,tem2,tem3-tem2)
     str2=replace(str2,"loopnum","")
     str2=replace(str2,"pid","")
     str2=replace(str2,"=","")
     str3=split(str2,",")
     pids=str3(1)
      end function
    '获取中间的HTML模板
    function htmls(str)
    tem1=1
       tem2=instr(tem1,str,"}")
       tem3=instr(tem1,str,"{/list}")
      str2=mid(str,tem2+1,tem3-(tem2+1))
     
    htmls=str2
    end function

    '确定字符串中模板变量不重复(例如str="deruiorptigt"其中r就是重复的,)
    'function midstr(str)
    'strnum=instr(str,"{list:")
    'strnum2=instr(str,"{/list}")
    'strnum2=strnum2+6
    'strlen=len(str)
    'str=left(str,strnum-1)&right(str,strlen-strnum2)
    'midstr=str
    'end function

    '在HTML中插入通过动态生成的HTML字符串
    'function addstr(str,addhtml)
    'tem1=1
    '   tem2=instr(tem1,str,"{list:")
    '      tem3=instr(tem1,str,"{/list}")
    '   strlen=len(str)
    'htmlleft=left(str,tem2-1)
    'htmlright=right(str,strlen-(tem3+6))
    'addstr=htmlleft&addhtml&htmlright
    'end function

    '获取模版<list></list>之间所有的字符串
    function mbstr(str)
       tem1=1
       tem2=instr(tem1,str,"{list:")
         tem3=instr(tem1,str,"{/list}")
      mbstr=mid(str,tem2,(tem3+7)-tem2)
      end function
    %>

  • 相关阅读:
    ABAP术语-Logical Lock
    ABAP术语-Lock Object
    ABAP术语-Lock Mode
    ABAP术语-Lock Argument
    ABAP术语-Key Field
    Python面向对象基础-day6
    Python中的内置模块与生成器迭代器-day5
    Python高阶函数与函数装饰器-day4
    Python字符编码与函数基本使用-day3
    Nginx内置变量及正则语法
  • 原文地址:https://www.cnblogs.com/yeye518/p/2231713.html
Copyright © 2011-2022 走看看