Another Canvas Update

Rob Gonda pointed out a bug in Canvas where it would throw an error when using a link as the first element. That has been fixed in the new release, 1.2.100. For the heck of it, I added three new “variablecomponents” to Canvas. Variable components are a method to add dynamic data to the Wiki. So for example, to include the version number of the current page, you simply do:

{version}

How hard is it to write these? Here is how version.cfc was built:

<cfcomponent hint="To display the page version, use {version}">

&lt;cffunction name="render" access="public" returnType="string" output="false"&gt;
	&lt;cfargument name="pageBean" type="any" required="true"&gt;
	
	&lt;cfreturn arguments.pageBean.getVersion()&gt;
	
&lt;/cffunction&gt;

</cfcomponent> </code>

Canvas uses the hint in the page editing help. It passes the pageBean to the render method and all you need to do is work with that object. Once you have written the CFC, you drop it in the proper folder and refresh the Model-Glue cache with init=true. That’s it.

So I added a few more of these. I also modified the last updated variable component to not prefix the result. This will let you add your own text to be placed in front of the date.

As always, you can download it from the project page.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments