有什么方法可以使用绑定或其他方式纠正 Rebol 构建标记函数吗?

发布于 2024-08-14 17:34:24 字数 1155 浏览 3 评论 0原文

下面的代码不起作用,因为我在彼此内部调用构建标记两次并使用相同的全局模板变量。有什么方法可以纠正构建标记,以便我可以传递本地模板变量?

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

This code below doesn't work because I call build-markup two times one inside each other and using the same Global Template variable. Any way to correct build-markup so that I can pass local Template variable ?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半衾梦 2024-08-21 17:34:24

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

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

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

'bind-markup is a refreshingly short function. It'd be relatively easy to copy it to your own script and add a parameter that would allow you to pass the target context through:

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

Then within the 'eval function where the loaded code is evaluated, change the block try [do val] to try [do bind load/all val any [:scope system/words]]. I believe that should do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文