Version 2.1 released    Releases

The last release of ajaxed has been five months ago (v2.0.1 end of December 2008) and so far more than 1600 downloads have been performed. It's good to see that ajaxed has become a common library when it comes to classic ASP and legacy applications. We are happy about all the contributions and suggestions over the past months as well.

Today, we are announcing the minor release of ajaxed - version 2.1. It does not contain too many fancy features. I would say the most additions are syntactic sugar ;)

Note: Upgrading from 2.0.1 to 2.1 should not cause any problems and does not require any changes of your existing files. Just download the new version and override your existing ajaxed/ folder.

Let's quickly walk through the new additions:

PostgreSQL support added

Thanks to iurisilvio ajaxed supports now PostgreSQL as well. He contributed the necessary changes and found some issues within the database tests. These bugs were fixed and his changes were merged into ajaxed.

TextTemplate placeholders default values

Now it's possible to specify default values for placeholders within your templates. Let's have a look at a template which uses default values:

Dear <<< name | unknown >>>,
We are happy you joined our website.

<<< sender | Your website team >>>

The template contains two placeholders name and sender. Both have a default value which will be used if no value is available. Great! Thanks to iurisilvio as well.

Add recordset to a TextTemplateBlock

Assume we have a a template like that:

Dear <<< customerName >>>,

Your ordered articles:
<<< block articles >>>
   Name: <<< name >>>
   Number :<<< nr | unknown >>>
<<< endblock articles >>>

Thank you for purchasing with us.

So far you had to add each block item manually to the template. In most cases we would have the items in a recordset though. Now we are able to add a whole recordset to the template (recordset fieldnames are mapped to the placeholder names within the block):

set t = new TextTemplate
t.filename = "template.txt"

'create a block and add the data from a recordset
set b = new TextTemplateBlock
b.addRS(db.getRS("SELECT * FROM ...", empty))

'add the block to the template
t.add "articles", b

Cool, isn't it? Idea from iurisilvio too ;) Thumbs up! I personally think we could improve that even more in the future. I am thinking of e.g. simple conditions within templates, default values which are evaluated as script e.g. <<< date | now() >>>. Default values if there is no code block, etc... okay that's gonna come in 2.2.

Creating disconnected recordset

We all know that it's sometimes a pain when working with arrays and dictionaries. It can get very confusing cause they are very limited data structures. I personally prefer recordsets whereever possible. Mainly because I can use column names which makes my code more readable. For that reason I have added a shortcut function (lib.newRecordset()) which will create a new disconnected recordset. The alias is ["R"](). Let's see some examples:

'creating new recordset
set rs = ["R"](array( _
  array("firstname", "lastname", "age"), _
  array("Lebron", "James", 20), _
  array("Britney", "Spears") _

'ready for looping...
while not rs.eof

'we can even skip columns
'age is skipped for the first record .. cause we do not know the age ;)
set rs = ["R"](array( _
  array("firstname", "lastname", "age"), _
  array("Barack", "Obama"), _
  array("David", "Copperfield", 50) _

That's really cool because it allows you to create powerful data structures easily without any confusing code. I recommend correct indenting though, otherwise it can get confusing with the brackets ;)

Tip: Not sure if you know the other useful aliased functions: [], ["D"]() and ["O"](). If not then check out the API ... They are useful!

DataContainer adding new items

The last addition is the adding facitlity for DataContainer. It allows us to add new items to a container instance easily. Here is a quick example:

'dynamically expanding an array
set dc = (new DataContainer)(array())
'chained add

'dictionary data container
with (new DataContainer)(["D"](empty))
  .add(array(1, "BWM"))
  .add(array(2, "Ford"))
  'updating the item with key 1
  .add(array(1, "Toyota"))
end with

set dc = (new DataContainer)(["R"](array( _
  array("brand", "ps"), _
  array("BWM", 200)
dc.add(array("Toyota", 100)).add(array("Mazda", 7))

That was it! It is not that much but it's something useful and should help us with new ideas on how to improve ajaxed more and more. Hope you enjoy and I am looking forward to your feedback.


Posted in Releases 5508 days ago

Version 2.1.1 Released4022 days ago