cf16-1代码什么意思
…posted by davidjmedlock:
…由 davidjmedlock 发布 :
Well, in about 7 hours I’m going to be on a plane to Salt Lake City, Utah for my first snowboarding trip. I’ve never been snowboarding or skiiing, so this should be interesting. I just hope I don’t break any important members. (I can live with a broken leg. A broken arm might impede my ability to code, though, and I don’t think worker’s comp will cover it.)
好吧,大约7个小时后,我将乘飞机前往犹他州盐湖城,这是我的第一次滑雪之旅。 我从来没有滑雪过,所以这应该很有趣。 我只是希望我不要破坏任何重要的成员。 (我可以用断腿的方式生活。但是,断臂可能会妨碍我的编码能力,而且我认为工作人员的助手不会掩盖它。)
Anyway, before I leave Nashville for the weekend, I wanted to post a brief blog on code reuse. I asked a while back what you all wanted to see in my blogs and articles and one reply was that you’d like to see something about creating custom tags. So, here you go. This will be a pretty brief description of how to create a simple tag, but I think you’ll get the point, and I’ll write more on it when I get back.
无论如何,在我周末离开纳什维尔之前,我想发表一个简短的博客,介绍代码重用。 我回想了一阵子,你们都想在我的博客和文章中看到什么,一个答复是,您希望看到有关创建自定义标签的内容。 所以,你去。 这将是关于如何创建一个简单标签的非常简短的描述,但是我想您会明白这一点的,回来时我会在上面写更多的内容。
First of all, any CFM file can be a custom tag. Try the following exercise. Create a file called “customtag.cfm”. Inside that custom tag, do this:
首先,任何CFM文件都可以是自定义标签。 试试下面的练习。 创建一个名为“ customtag.cfm”的文件。 在该自定义标签内,执行以下操作:
#Attributes.Hello#
#Attributes.Hello#
Save it to your web root and then create a file called “tagtest.cfm”. This file looks like this:
将其保存到您的Web根目录,然后创建一个名为“ tagtest.cfm”的文件。 该文件如下所示:
First let’s examine the customtag.cfm file. Notice that we’re parameterizing (is that a word?) the “Attributes.Hello” variable. The attributes scope is generally only available within custom tags and modules, although there are some exceptions which we won’t get into right now. Notice the second line of our “tagtest.cfm” file. We pass in the attribute “Hello”.
首先,让我们检查customtag.cfm文件。 注意,我们正在参数化(是一个词吗?)“ Attributes .Hello”变量。 属性范围通常仅在自定义标签和模块中可用,尽管有一些例外情况我们暂时不讨论。 注意“ tagtest.cfm”文件的第二行。 我们传入属性 “ Hello”。
Also notice the name of the tag we’re calling: cf_customtag. ColdFusion custom tags (not CFX tags) are always called using “cf_” and then the name of the file (excluding the extension). You can then pass any attributes that you want into the tag. These attributes are completely defined by you. Just make sure they follow then naming requirements for ColdFusion variables.
还要注意我们正在调用的标签的名称:cf_customtag。 始终使用“ cf_”,然后使用文件名(不包括扩展名)来调用ColdFusion自定义标签(不是CFX标签)。 然后,您可以将所需的任何属性传递到标签中。 这些属性完全由您定义。 只要确保它们遵循然后命名ColdFusion变量即可。
So you can see here the very basics of custom tags:
因此,您可以在此处查看自定义标签的基本知识:
- The name of the tag is “cf_” and then the name of the template file 标签的名称是“ cf_”,然后是模板文件的名称
- The attributes specified in the tag called go into the “Attributes” scope available inside the tag template. 在称为的标签中指定的属性进入标签模板内可用的“属性”范围。
It’s also important to note that if you move “/tagtest.cfm” to “/test/tagtest.cfm” you will get an error saying that the custom tag template was not found. This is because ColdFusion looks in only certain places for custom tags:
同样重要的是要注意,如果将“ /tagtest.cfm”移至“ /test/tagtest.cfm”,则会收到一条错误消息,指出未找到自定义标签模板。 这是因为ColdFusion仅在某些位置查找自定义标签:
- The directory that the current template is in. 当前模板所在的目录。
Any custom tag directories specified in ColdFusion Administrator. This means you can use either the default “ CustomTags” directory or specify that your custom tags are in “C:mytags”. This is done from within the Administrator itself.
在ColdFusion管理员中指定的任何自定义标签目录。 这意味着您可以使用默认的“ CustomTags”目录或指定您的自定义标签在“ C:mytags”中。 这是在管理员本身内部完成的。
So there’s a start. Next week, we’ll talk about custom tag encapsulation and returning variables from custom tags. In the meantime you can visit CFLib and KodeFusion Scripts for some free custom tags to examine.
所以有一个开始。 下周,我们将讨论自定义标签封装和从自定义标签返回变量。 在此期间,您可以访问CFLib和KodeFusion脚本以获取一些免费的自定义标签进行检查。
cf16-1代码什么意思