RSSThe TSW Blog

The making of "WebCoder.NET" – part 8

April 7, 2007

One thing that you learn when creating a web editor is the fact that every person has their own style when it comes to writing a HTML tag. As a person who spends of time writing way more strict programming languages, as well as writing code for parsing HTML tags, I'm not very fond of the lose nature of HTML. Fortunately, XHTML is more strict when it comes to how your tags should be written, which makes it easier to parse, but since people still write standard HTML as well, WebCoder needs to support this too. However, supporting it is not always enough. WebCoder can output HTML in all sorts of ways, but in previous versions, the output was styled the way I preferred it - tags and attributes in lowercase and doublequotes surrounding all values. That was the way the dialogs outputted HTML, the way the IntelliSense features would output it, and so on. 

With WebCoder.NET, this has all changed. You may now decide casing for tags and attributes, as well as the quotes you may or may not wish to use for values. Almost a 1.000 lines of code in "WebCoder.NET" has been dedicated to the handling, parsing and outputting of HTML tags, which will ensure a more consistent input and output. The really cool part is that the HtmlTag class is used in all XML/Scripting dialogs too, and you may use it in your own scripts as well! This means that you can write scripts which outputs tags just the way the user wants it. This make generating HTML tags much cleaner - just look at the following example where we build an HTML tag, and then insert it into the currently active document:

from TSW.WebCoder.Classes import HtmlTag

tag = HtmlTag("div")
tag.AddAttribute("class", "testClass")
tag.AddAttribute("style", "text-align: center;")

tag.PhpEscapeOutput = False

ScriptUtils.InsertCode(tag.GetMarkup(True))

It's all very simple and quite nice to look at, I think. Once the GetMarkup() method is called, WebCoder formats the tag according to your tag settings, and return the tag just the way you want it. It's one of those minor things which makes me love "WebCoder.NET" a lot more :)

Kasper (TSW) @ 11:05 am in WebCoder

One Response to “The making of "WebCoder.NET" – part 8”

  1. Kevin says:

    sweet!

Leave a Reply