This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.cfm
55 lines (50 loc) · 1.92 KB
/
index.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!--- make sure the liquid library is loaded in the application scope --->
<cfif !StructKeyExists(application, "liquid")>
<cfset application.liquid = createObject("component", "lib.Liquid").init()>
</cfif>
<!--- create our template object --->
<cfset template = application.liquid.template()>
<!--- create the source we want to parse --->
<cfsavecontent variable="source">
<h1>{{ pageTitle }}</h1>
{% if query.size %}
<ul>
{% for item in query %}
<li>{{ item.project }} - <a href="{{ item.link }}">{{ item.link }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No records found</p>
{% endif %}
</cfsavecontent>
<!--- lets assign some variables to the source --->
<!--- create a mock query for showing what this thing can do --->
<cfset q = QueryNew("project,link")>
<cfset QueryAddRow(q)>
<cfset QuerySetCell(q, "project", "CFWheels")>
<cfset QuerySetCell(q, "link", "https://github.com/cfwheels/cfwheels")>
<cfset QueryAddRow(q)>
<cfset QuerySetCell(q, "project", "ColdMVC")>
<cfset QuerySetCell(q, "link", "https://github.com/tonynelson19/ColdMVC")>
<cfset QueryAddRow(q)>
<cfset QuerySetCell(q, "project", "FW/1")>
<cfset QuerySetCell(q, "link", "https://github.com/seancorfield/fw1")>
<cfset QueryAddRow(q)>
<cfset QuerySetCell(q, "project", "Fusebox")>
<cfset QuerySetCell(q, "link", "https://github.com/fusebox-framework/Fusebox-ColdFusion")>
<!--- create a structure to pass in --->
<cfset assigns = {query = q, pageTitle = "ColdFusion Frameworks on Github"}>
<!---
NOTE: if there are any errors in the source, a LiquidError exception will be thrown
Always wrap the calls to Liquid in a try/catch block so you can display
the parsing errors to the user.
--->
<cftry>
<!--- parse the source --->
<cfset template.parse(source)>
<!--- render the output --->
<cfoutput>#template.render(assigns)#</cfoutput>
<cfcatch type="LiquidError">
<cfoutput>#cfcatch.message#</cfoutput>
</cfcatch>
</cftry>