Skip to main content

Tag replace - Actions in ColdFusion Builder

Tag search is that one powerful feature in ColdFusion Builder 2.0 which allows you to search for tags that match some criteria. Also, there are various actions that the user can perform once the tag is found. Actions such as
  •  'Replacing the tag block' with some text,
  •  'Removing the Tag block', 
  •  'Setting an attribute', 
  •  'Removing an attribute',
  •  'Adding text before the tag block' and
  •  'Adding text after the tag block'. 
In this post I'll explain how these actions can help you increase your productivity in your day to day application development.

Action - Setting an attribute

Consider a use-case where you would like your ColdFusion application to be available to other web clients such as a HTML client or a FLEX client. In these cases you will have to update the cffunction's access attribute to remote. Updating each and every function definition can be a time consuming task. With the action Set attribute one can specify the attribute that you would like to update with the given value:


As we can see in the above screenshot, a condition 'cffunction tag with attribute access is Any value' is specified (i.e. the tag search engine would search for cffunction tags whose access attribute will be any value). The action selected is Set attribute with attribute access selected with its value set to remote. On clicking 'Replace All', all cffunction tags in the CFC will now have the access attribute set to remote. How easy was that? Gone are the days when you had to go through the entire file and update the tag attributes where ever required.

If you specify an attribute which doesn't exist, then the attribute would be added to the tag definition. Action Set Attribute is used for both adding and updating the tag definitions.

Action - Remove attribute

Action Remove attribute is used to remove an attribute from the tag. So if you would like to remove an attribute, say output attribute of cffunction tag, then select Remove attribute as the action and specify the attribute that you would like to remove:


Actions - Adding text before and after the tag block

While editing a CFC containing various cffunction tags, there are times when you would like to add a generic comment before the function definition, stating its description. Also you would want to add a comment stating the end of the function tag block at the end of the cffunction tag. With the new Tag search, you can specify the tag as cffunction and then add a condition (if required) and click 'Add'. Now in the Action list, select Add before Tag and specify the text that you would like to add. In this case, it would be a comment as shown in the picture below:


Click on Replace All and you will see that the comment is added before the tag block.

Similarly, in case of Adding text after the tag block, select Add after tag and specify the text that you want to add after the function definition:


Again, click 'Replace All' to add the comment at the end of every function definition.

Actions - Replace tag block and Remove tag block


Other actions provided include Replacing a tag block and Removing a tag block. As the name suggests, on selecting the action Replace tag block, the tag block is replaced with the text that the user has provided:


Similarly if you would like to remove the tag block, then select the action Remove tag block:


All the actions mentioned above can be performed in all the scopes. Please refer to my previous post where in I have describe various scopes available for both text and tag search. 

Comments

  1. That is a pretty cool feature! I need to get my hands on that beta. I really want to start playing with the plugins again.

    ReplyDelete
  2. Hey Sagar,

    Would you consider becoming a DZone.com MVB?

    www.dzone.com/aboutmvb

    You can reach our curator through that link.

    Best,
    Mitch

    ReplyDelete

Post a Comment

Popular posts from this blog

Custom validation messages for HTML5 Input elements using the constraint validation API

HTML5 has introduced several input types such as EMAIL, URL, RANGE, SEARCH, DATE, TIME, etc,. Most of the modern browsers have implemented them and are ready to be used in a HTML document. Another exciting feature introduced in HTML5 is the form validation. Instead of writing JavaScript to validate users input, browsers can now validate it and show an appropriate message if the validation fails. The validation message is shown in line with the field for which the validation has failed. The default error message is shown when the validation fails. In this post I'll explain how these error messages can be changed.

Adding beforeRender and afterRender functions to a Backbone View

I was working on a Backbone application that updated the DOM when a response was received from the server. In a Backbone View, the initialize method would perform some operations and then call the render method to update the view. This worked fine, however there was scenario where in I wanted to perform some tasks before and after rendering the view. This can be considered as firing an event before and after the function had completed its execution. I found a very simple way to do this with Underscore's wrap method.

De-obfuscating javascript code in Chrome Developer Tools

I had blogged about JavaScript debugging with Chrome Developer Tools some time back, wherein I have explained how these developer tools can help in debugging javascript code. Today Google Chrome 12 was released and my Chrome browser was updated to this version. As with every release, there have been some improvements made on performance, usability etc,. One feature that stood out for me is the ability to De-obfuscate the javascript code.

What is Minification?

Minification is the process of removing unnecessary characters such as white spaces, comments, new lines from the source code. These otherwise would be added to make the code more readable. Minifying the source code helps in reducing the file size and thereby reducing the time taken to download the file. This is the reason why most of the popular javascript libraries such as jQuery are minified. A minified jQuery file is of 31 KB in size where as an uncompressed one is about 229 KB. Unfortunately, debugging minified javascript file…