I'd like to implement {config_load} next.
{config_load file="filename.ext" section="section_name"}
{config_load} loads variables for use in the template. You will be able to access these values with hash marks: {#variablename#}. "section" is optional. You'll be able to load only the portion of the config file that you need.
Here is Smarty's explanation for {config_load}:
http://www.smarty.net/manual/en/language.function.config.load.php
I think I'll only be able to implement the "file" and "section" parameters. I don't think I'll be able to implement the "scope" parameter, because I'm not sure how much control I'll have in controlling the scope of variables.
After finishing {config_load}, I think I'll bump up the version number from 1.0 to 1.1.
Tuesday, November 24, 2009
Added truncate modifier
I just finished adding the truncate variable modifier. It cuts off a string at either 80 characters, or some number of characters you indicate. Smarty has more options, and I'd like to add them later, but this is good enough for now.
Working on truncate
I'm working on the truncate modifier.
{ $strVariable|truncate }
{ $strVariable|truncate:intLength }
Truncate will end a string variable's output to a character length. If no length is given, the default intLength value is 80. It will try to cut off at a word boundary before the intLength value. Smarty's truncate has some additional optional parameters, but I don't think I'll be able to implement it fully very soon. So, I'll just implement the length parameter, for now.
Also, I'm going back and forth regarding implementing dynamic includes in Dermis. The difficulty is that Dermis would have to determine if the .tpl.file needs to be compiled at every occurrence of an {include} tag. If it is, this means that the Dermis compiler would need to be invoked. Therefore, the Dermis code would need to be #included once the script begins.
{ $strVariable|truncate }
{ $strVariable|truncate:intLength }
Truncate will end a string variable's output to a character length. If no length is given, the default intLength value is 80. It will try to cut off at a word boundary before the intLength value. Smarty's truncate has some additional optional parameters, but I don't think I'll be able to implement it fully very soon. So, I'll just implement the length parameter, for now.
Also, I'm going back and forth regarding implementing dynamic includes in Dermis. The difficulty is that Dermis would have to determine if the .tpl.file needs to be compiled at every occurrence of an {include} tag. If it is, this means that the Dermis compiler would need to be invoked. Therefore, the Dermis code would need to be #included once the script begins.
Friday, November 20, 2009
Dynamic includes might be possible
Despite what nearly everyone says, dynamic includes may be possible in ASP. You just have to go through some effort to do so.
Dermis passes variables from ASP to the compiled Dermis file using session variables. It then shells to the compiled file using the server.execute("filename.asp") command. When you use the server.execute command, the called script cannot see variables (or code) from the parent (i.e., calling) script. However, session variables are outside of the variable space. So, Dermis can copy ASP variables into session variables, server.execute the script, return to the parent script, and delete the session variables.
(Incidentally, once the server.execute command finishes, the parent script can see its own variables again. Because of this, you can call sequential objT.display("filename.tpl") commands. But I digress...)
Right now, {include} compiles to <!--#include--!>. However, after a bit of searching, I found a site that has given me an idea. Using server.execute instead of #include may be a better solution, because you can have:
server.execute(strFilename)
server.execute(strDirectory & "/filename.tpl.asp")
server.execute(strDirectory & "/" & strLanguage & "/filename.tpl.asp")
...and such. However, the hard part will be how to compile an {include} file with variable components, because you don't know what the final filename will be until you run the code. (I think this is called "just in time" compiling.) Because we've shelled into a running script, and we can't see parent variables or code, I think the only solution is to somehow write the resolved filename to a session variable, exit the script, create the included file using the session variable, re-start the script, and go from there.
I have to think about this some more, but something in me tells me there's a way to do this!
Dermis passes variables from ASP to the compiled Dermis file using session variables. It then shells to the compiled file using the server.execute("filename.asp") command. When you use the server.execute command, the called script cannot see variables (or code) from the parent (i.e., calling) script. However, session variables are outside of the variable space. So, Dermis can copy ASP variables into session variables, server.execute the script, return to the parent script, and delete the session variables.
(Incidentally, once the server.execute command finishes, the parent script can see its own variables again. Because of this, you can call sequential objT.display("filename.tpl") commands. But I digress...)
Right now, {include} compiles to <!--#include--!>. However, after a bit of searching, I found a site that has given me an idea. Using server.execute instead of #include may be a better solution, because you can have:
server.execute(strFilename)
server.execute(strDirectory & "/filename.tpl.asp")
server.execute(strDirectory & "/" & strLanguage & "/filename.tpl.asp")
...and such. However, the hard part will be how to compile an {include} file with variable components, because you don't know what the final filename will be until you run the code. (I think this is called "just in time" compiling.) Because we've shelled into a running script, and we can't see parent variables or code, I think the only solution is to somehow write the resolved filename to a session variable, exit the script, create the included file using the session variable, re-start the script, and go from there.
I have to think about this some more, but something in me tells me there's a way to do this!
Thursday, November 19, 2009
Added {strip} tag
I added the {strip} tag! Just like Smarty, it removes leading and trailing whitespace around newlines (vbcrlf) in the compiled code, as well as the newlines themselves. The {/strip} tag is optional.
I've only tested it with one {strip} in a file. I'll test it with several soon, in the next few days.
I also added breadcrumbs to the documentation. No big deal, but it makes it look a bit nicer.
I've only tested it with one {strip} in a file. I'll test it with several soon, in the next few days.
I also added breadcrumbs to the documentation. No big deal, but it makes it look a bit nicer.
Dermis 1.0
Dermis 1.0 is out! I'm very excited!
Documentation finally looks decent!
After thinking about it for a while, I decided to call it 1.0 after the documentation was acceptable.
For the documentation, I modified a free layout I found called "Artificial Castling" (wrongly called Artificial Casting). Of course, I linked back to where I got it from in the footer, as the author requested.
It took me a few hours to write the code to distribute the single large documentation file into multiple files. It took me about as long to get the stylesheet code tamed.
I also think I may have a better workaround for using Dermis on IIS+XP: if the .tpl file is modified, just delete the old .tpl.asp immediately before writing the updated .tpl.asp file. It will only do this on XP (actually, non-"windows nt"), because Server 2003 doesn't have this problem, and I want to minimize the permissions needed for the system.
As you use it, let me know where you're from, and how you're using it!
Documentation finally looks decent!
After thinking about it for a while, I decided to call it 1.0 after the documentation was acceptable.
For the documentation, I modified a free layout I found called "Artificial Castling" (wrongly called Artificial Casting). Of course, I linked back to where I got it from in the footer, as the author requested.
It took me a few hours to write the code to distribute the single large documentation file into multiple files. It took me about as long to get the stylesheet code tamed.
I also think I may have a better workaround for using Dermis on IIS+XP: if the .tpl file is modified, just delete the old .tpl.asp immediately before writing the updated .tpl.asp file. It will only do this on XP (actually, non-"windows nt"), because Server 2003 doesn't have this problem, and I want to minimize the permissions needed for the system.
As you use it, let me know where you're from, and how you're using it!
Saturday, November 14, 2009
Caching & Date
Okay, that IIS+XP caching bug REALLY was getting on my nerves! Even better, I think I have it solved. Clearing an IIS checkbox called "Cache ISAPI applications" did the trick. I've documented it, too. Hooray!
I also think I solved some date issues, too. They have to do with using VBScript's date type. I'm hoping it will translate into preserving database (MS Access & SQL Server) timestamps, too. More on that later.
Oh, yeah. I forgot to change the internal version number from 0.5 to 0.6. It didn't cause a bug. It was just a silly oversight on my part.
I'll upload the .zip file in about 10 minutes, assuming I don't see anything else.
I also think I solved some date issues, too. They have to do with using VBScript's date type. I'm hoping it will translate into preserving database (MS Access & SQL Server) timestamps, too. More on that later.
Oh, yeah. I forgot to change the internal version number from 0.5 to 0.6. It didn't cause a bug. It was just a silly oversight on my part.
I'll upload the .zip file in about 10 minutes, assuming I don't see anything else.
Friday, November 13, 2009
Documentation & Bug
I've added code to the documentation which uses the append method. I've also added some HTML output to show results of running code, and left the ASP & TPL files.
The documentation is still one very long file. It's cumbersome to learn from and sloppy, I'm sure, but it's easier and faster for me to write it while it's just one file.
I also discovered an annoying bug that I'm not sure I can correct. When you update a .TPL file, the browser output doesn't change! The compiled .tpl.asp is being updated, and using different data from the calling .asp script outputs different results, so I think IIS may be running the .asp script from somewhere other than c:\inetpub\wwwroot\var\templates_c. So far, I'm only seeing it on IIS+XP+IE+Dermis, but I haven't checked Win2003 or Firefox because I discovered it only a few hours ago. It's 11:30 pm, and I want to go to bed. Good-night!
The documentation is still one very long file. It's cumbersome to learn from and sloppy, I'm sure, but it's easier and faster for me to write it while it's just one file.
I also discovered an annoying bug that I'm not sure I can correct. When you update a .TPL file, the browser output doesn't change! The compiled .tpl.asp is being updated, and using different data from the calling .asp script outputs different results, so I think IIS may be running the .asp script from somewhere other than c:\inetpub\wwwroot\var\templates_c. So far, I'm only seeing it on IIS+XP+IE+Dermis, but I haven't checked Win2003 or Firefox because I discovered it only a few hours ago. It's 11:30 pm, and I want to go to bed. Good-night!
Dermis 0.6
I've released Dermis 0.6. (An upgrade from 0.5! Whoo-hoo!)
The display method and {include} tag can now handle relative and absolute directories.
Here's some of my test code:
objT.display("header.tpl")
objT.display("dermistest\header.tpl")
objT.display("dermistest\dermistest\header.tpl")
objT.display("\header.tpl")
objT.display("\dermistest\header.tpl")
objT.display("\dermistest\dermistest\header.tpl")
{ include file="header.tpl" }
{ include file="dermistest\header.tpl" }
{ include file="dermistest\dermistest\header.tpl" }
{ include file="\header.tpl" }
{ include file="\dermistest\header.tpl" }
{ include file="\dermistest\dermistest\header.tpl" }
I'm not sure what criteria there is for a 1.0 release. Perhaps breaking up the documentation into separate files.
The display method and {include} tag can now handle relative and absolute directories.
Here's some of my test code:
objT.display("header.tpl")
objT.display("dermistest\header.tpl")
objT.display("dermistest\dermistest\header.tpl")
objT.display("\header.tpl")
objT.display("\dermistest\header.tpl")
objT.display("\dermistest\dermistest\header.tpl")
{ include file="header.tpl" }
{ include file="dermistest\header.tpl" }
{ include file="dermistest\dermistest\header.tpl" }
{ include file="\header.tpl" }
{ include file="\dermistest\header.tpl" }
{ include file="\dermistest\dermistest\header.tpl" }
I'm not sure what criteria there is for a 1.0 release. Perhaps breaking up the documentation into separate files.
Finished append method
The "append" method works now! I haven't documented it yet. For now, look at the code in default.asp to see how to use it.
Now, I need to fix the display method and {include}, because they can't handle directories yet:
objT.display("bluelayout/default.tpl") ' - doesn't work yet
{include file="bluelayout/header.tpl") ' - doesn't work yet
Perhaps I'll move it from Dermis 0.5 to 0.6 after this.
Now, I need to fix the display method and {include}, because they can't handle directories yet:
objT.display("bluelayout/default.tpl") ' - doesn't work yet
{include file="bluelayout/header.tpl") ' - doesn't work yet
Perhaps I'll move it from Dermis 0.5 to 0.6 after this.
Thursday, November 12, 2009
Download the .zip file only
Download the Dermis .zip file only, not from SVN.
https://sourceforge.net/projects/dermis/
At least, don't download from SVN for a while. I upload the .zip file when there are no (known) bugs. The SVN code is my "working folder," and often has bugs.
https://sourceforge.net/projects/dermis/
At least, don't download from SVN for a while. I upload the .zip file when there are no (known) bugs. The SVN code is my "working folder," and often has bugs.
Sidetracked
Okay, so I haven't finished the "append" method yet. But, I wasn't slacking!
I was using the {foreach} tag to test my fledgling "append" method code, and discovered some weaknesses with {foreach}. So, I re-wrote the compiled output code for the {foreach} tag. It was tougher than I thought. I had to start at square one: smarty.net {foreach} examples, and about 70 lines of pseudo-code in ASP, just so I could get the big picture. However, the end result was worth it. {foreach} compiles to much nicer, and probably stronger, code.
I also discovered (and more importantly, FIXED) a huge {include} issue. The chance for a variable collision in the compiled code (i.e., two identically-named variables) was guaranteed if there were two include statements that both use {foreach} or {section}. Now, compiled filenames have incrementing numbers, even different filenames.
I was using the {foreach} tag to test my fledgling "append" method code, and discovered some weaknesses with {foreach}. So, I re-wrote the compiled output code for the {foreach} tag. It was tougher than I thought. I had to start at square one: smarty.net {foreach} examples, and about 70 lines of pseudo-code in ASP, just so I could get the big picture. However, the end result was worth it. {foreach} compiles to much nicer, and probably stronger, code.
I also discovered (and more importantly, FIXED) a huge {include} issue. The chance for a variable collision in the compiled code (i.e., two identically-named variables) was guaranteed if there were two include statements that both use {foreach} or {section}. Now, compiled filenames have incrementing numbers, even different filenames.
Thursday, November 5, 2009
Adding append method
I'm working on an "append" method, similar to Smarty's. I should finish in a few days.
Wednesday, November 4, 2009
Potential error fixed
The old code would declare variables immediately before using them. However, I was thinking last night, "What if the user implements nested loops using foreach or section?? ASP won't go past re-declaring variables!"
A feeling of dread overcame me! (Okay... maybe I'm being too melodramatic.) But it was a serious issue I needed to correct quickly.
So, I made some changes where variables are declared at the top of the compiled file instead of immediately before it is used.
I've been committing to SVN all along, but overwriting dermis0.5.zip over and over again. I know it is bad practice to use the same version number. Once Dermis takes off, I'll use different version numbers.
A feeling of dread overcame me! (Okay... maybe I'm being too melodramatic.) But it was a serious issue I needed to correct quickly.
So, I made some changes where variables are declared at the top of the compiled file instead of immediately before it is used.
I've been committing to SVN all along, but overwriting dermis0.5.zip over and over again. I know it is bad practice to use the same version number. Once Dermis takes off, I'll use different version numbers.
Tuesday, November 3, 2009
Uploaded
The files weren't appearing because uploading via SVN is different than "uploading files." They can be downloaded via a zip file now (or SVN).
https://sourceforge.net/projects/dermis/
As far as I know, it's the only Smarty port to ASP/VBScript I know of. I'm excited about releasing it into the wild!
If you are using it, let me know, only so I can brag to my friends!
https://sourceforge.net/projects/dermis/
As far as I know, it's the only Smarty port to ASP/VBScript I know of. I'm excited about releasing it into the wild!
If you are using it, let me know, only so I can brag to my friends!
Monday, November 2, 2009
Uploading
I'm trying to upload the files for Dermis now via SVN. They haven't appeared yet, but I think it's because of sourceforge's 15 minute delay plastered all over their site.
I realize that the documentation may be hard to find. Sorry about that!
You can download the files from here: http://dermis.svn.sourceforge.net/viewvc/dermis/trunk/
Once you download the files, the documentation can be found here: /html/index.html
Right now, the documentation is all contained in one file, and none of the links work.
I realize that the documentation may be hard to find. Sorry about that!
You can download the files from here: http://dermis.svn.sourceforge.net/viewvc/dermis/trunk/
Once you download the files, the documentation can be found here: /html/index.html
Right now, the documentation is all contained in one file, and none of the links work.
Subscribe to:
Posts (Atom)