有什么方法可以使用bind或其他什么来纠正Rebol构建标记函数?

时间:2009-12-10 18:01:09

标签: rebol

下面这段代码不起作用,因为我将build-markup彼此调用两次并使用相同的Global Template变量。有没有办法纠正构建标记,以便我可以传递本地模板变量?

Template: {<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Free PHP Gallery - web-templates.nu</title>
<meta name="Description" content="This is a template of a free php gallery." />
<meta name="Keywords" content="template, gallery, php, free" />
<link rel="stylesheet" href="gallery/style_gallery.php" type="text/css" media="screen" />
</head>

<body>

<!-- ##### Include your gallery class and gallery between the body-tags ##### 
#
# To add images to your gallery, change the ADD-IMAGES.PHP
# To change the look of the gallery, change the SETTINGS.PHP
#
##### -->

<div class="gallery">
<%do %galleryview.cgi "" %>
</div>

<!-- ##### That's it, just copy and paste the line above ##### -->

</body>
</html>}

print build-markup Template

1 个答案:

答案 0 :(得分:1)

'bind-markup是一个令人耳目一新的短暂功能。将它复制到您自己的脚本并添加一个允许您通过目标上下文传递的参数相对容易:

build-markup: func [
    ...
    /with scope [word! object!]
]

然后在评估加载代码的'eval函数中,将块try [do val]更改为try [do bind load/all val any [:scope system/words]]。我相信应该这样做。