<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gorges Blog &#187; Web Development</title>
	<atom:link href="http://blog.GORGES.us/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.GORGES.us</link>
	<description>Web Sites that Grow Your Business - our blog</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:34:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Website Search Strategies</title>
		<link>http://blog.GORGES.us/2012/02/website-search-strategies/</link>
		<comments>http://blog.GORGES.us/2012/02/website-search-strategies/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 13:32:42 +0000</pubDate>
		<dc:creator>Don Ellis</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[User Interface UX]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=750</guid>
		<description><![CDATA[Search strategies should relate to a website’s mission and message.]]></description>
			<content:encoded><![CDATA[<p>Search strategies should relate to a website’s mission and message. They also need to respond to the anticipated user skills and preferences – optimal search strategies on a website for scientist or engineers would be quite different from those for the general public.</p>
<p>Search is really just part of navigation. In many cases information found by running a search routine can also be found by just browsing through the pages. Which serves the visitor best? … is that also what serves the mission best?</p>
<p>Search needs words (also phrases) for searching. When visitors compose their own phrases, will those phrase be effective in searching the website? If not, then search terms should be offered as items in drop-down lists or some similar selection interface.</p>
<p>Next there is the question of what will be searched. A Google-like search can theoretically see every word in the public space of the website. Will this work OK? … will many irrelevant items be returned? … or should that type of “free word” search be used, but restricted to parts of the space with relevant content?</p>
<p>Another approach uses either “free word” input or “selected word” input to search only prepared fields in the database. This allows the web administrators to help or control the search results, but requires maintaining those fields of search phrases.</p>
<p>Many choices and variations are possible. Least expensive is installing one of the free search routines, one that can be limited to just the one website, as Google can. It has quick setup, little maintenance, is familiar to nearly everyone, but in a small website it can be quite imprecise and may often return empty lists.</p>
<p>I recommend a careful discussion with your website’s Information Designer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2012/02/website-search-strategies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress or Drupal</title>
		<link>http://blog.GORGES.us/2012/01/wordpress-or-drupal/</link>
		<comments>http://blog.GORGES.us/2012/01/wordpress-or-drupal/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 13:24:22 +0000</pubDate>
		<dc:creator>Don Ellis</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=728</guid>
		<description><![CDATA[GORGES does not have any intrinsic preference between, Drupal and Wordpress. We can and will provide either. Several recent clients have posed this choice. We think this choice needs to be based in the technology.]]></description>
			<content:encoded><![CDATA[<p>GORGES does not have any intrinsic preference between, Drupal and WordPress. We can and will provide either. Several recent clients have posed this choice. We think this choice needs to be based in the technology.</p>
<p>Wanting to be as unbiased as possible, I have researched online several times and offer these two third-party views:<br />
<a href="http://www.bivingsreport.com/2007/wordpress-vs-drupal/">http://www.bivingsreport.com/2007/wordpress-vs-drupal/</a><br />
<a href="http://www.quis.com/2009/06/01/drupal-vs-wordpress">http://www.quis.com/2009/06/01/drupal-vs-wordpress</a></p>
<p>Both articles try to be unbiased, and I think they succeed. Neither writes that WordPress and Drupal are on the same plane. They both assign WordPress to the simplest of websites and Drupal to the next echelon. This matches our considerable experience. WordPress provides an elegantly ease-to-use CMS. It is the appropriate choice for lightly featured blogs and very simple websites.</p>
<p>Here’s the experience of someone who “loves” WordPress (the language needs editing):<br />
<a href="http://kevinjohngallagher.com/2012/01/wordpress-has-left-the-building/">http://kevinjohngallagher.com/2012/01/wordpress-has-left-the-building/</a></p>
<p>The Drupal community is on a different track. Drupal is a machine for making interactive websites &#8211; newspapers, magazines, large corporate websites, online stores. In the spectrum of technology, Drupal picks up where WordPress leaves off, and takes us toward standard web applications. When the project no longer fits “standard things you do on a website,” it is a web application that requires a web application framework. GORGES will in that case recommend the appropriate framework, maybe Ruby on Rails, Yii, or .NET.</p>
<p>It should also be noted, that when a client is engaging GORGES to perform setup, to propose designs, to guide the process and provide training, the distinctions having to do with ease of setup, theme decisions, and ease of use become inconsequential. GORGES shoulders those.</p>
<p>The differences between WordPress and Drupal are finally differences in capability. What interactive features does your website need now and how likely are you to want significant visitor interaction in the future? Is the site to be a one-time undertaking, or is it likely to grow thought time? If these are not issues, WordPress might be just right.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2012/01/wordpress-or-drupal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Choosing Web Chart Technologies</title>
		<link>http://blog.GORGES.us/2011/12/choosing-web-chart-technologies/</link>
		<comments>http://blog.GORGES.us/2011/12/choosing-web-chart-technologies/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 13:20:01 +0000</pubDate>
		<dc:creator>Jim Tse</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=731</guid>
		<description><![CDATA[Web-based charting has emerged as another great use of the browser. Traditionally, business analysts were the ones crunching numbers on spreadsheet to build charts. The spreadsheet would be e-mail as a file attachment. This process of compiling numbers and chart building could take hours. There is the saying that once information is on paper, it [...]]]></description>
			<content:encoded><![CDATA[<p>Web-based charting has emerged as another great use of the browser. Traditionally, business analysts were the ones crunching numbers on spreadsheet to build charts. The spreadsheet would be e-mail as a file attachment. This process of compiling numbers and chart building could take hours. There is the saying that once information is on paper, it is already outdated. It will not be long before the saying becomes: Once information is in an office file document, it is already outdated. As a result, the web is quickly becoming the preferred platform for data charting and analysis.</p>
<p>In this article, we will discuss approaches to creating charts on the web. Currently, there are two general approaches to creating charts on the web: Image-based versus Scalable Vector Graphics (SVG)-based. There are also Flash-based solutions but we cannot recommend them because Flash is not available on iPhones and iPads and the future of Flash-based solution is uncertain.</p>
<p>Image charts<br />
Here, the server generates a static image (e.g., a JPEG) of the chart from the data and the image gets displayed in the browser. There are a plethora of server-side charting implementations to choose from &#8212; a noteworthy one is Google Image Charts: http://code.google.com/apis/chart/image. Since the chart is simply an image, there are no cross-browser issues and the look of the chart is also consistent across browsers. The chart can easily be exported for usage in presentation slides since the chart is just an image file. However, the disadvantage of this approach is that users cannot interact with the chart; they cannot click into a pie chart slice or hover over line graph points to better understand the data being presented. While image-based charts provide a consistent and reliable view of the data, this approach does not give your end users necessary usability needed to make effective use of the information.</p>
<p>SVG charts<br />
Here, the rendering of the chart is strictly on the client browser: There is no server-side rendering of the chart. Data are passed into a JavaScript SVG library which renders the chart as SVG markup (or VML markup if the user is on Internet Explorer 6/7/8). The browser produces a chart from the resulting markup that is mostly consistent across browsers. (We have run into an edge case issue where labels on pie charts get cut-off in Internet Explorer.) Exporting the chart into a file for use in presentation slides is a little trickier &#8212; since SVG charts are derived from JavaScript libraries and you cannot create files using JavaScript (at least not easily or consistently across browsers). One possible solution is to post the serialized SVG output back to the server-side and convert into the desired target format (e.g., JPEG, PDF, etc.). These relatively minor issues are offset by the huge gain in chart interactivity. SVG charting libraries allows developers to attach mouse click and hover events to the charts, such that a user can drill down into a pie slice of a chart or hover over line graph points for a more comprehensive view of the data. The SVG charting libraries tend to be relatively easy to use for developers comfortable with JavaScript, relative to the server-side charting tools.</p>
<p>Choosing a solution<br />
When choosing a charting solution, it is necessary to consider the following requirements:</p>
<ul>
<li>Does the chart have to be interactive? If the answer is a resounding yes, then SVG approaches are the only options.</li>
<li>How important is exporting chart into other file format? If very important, then it may be worthwhile to look at image-based solutions or possibly dual solutions of both SVG and static images.</li>
<li>Are we dealing with tens of thousands of data points? If yes, then it may be neccessary to sacrifice the interactivity of SVG charts for performance of static image charts.</li>
</ul>
<p>SVG solutions<br />
Below is a brief descriptive of three SVG libraries. This is by no means a comprehensive list.</p>
<ul>
<li>gRaphael: http://g.raphaeljs.com</li>
<ul>
<li>Only completely free solution of the three.</li>
<li>Not as mature the others and poorly documented.</li>
<li>Programming somewhat easy.</li>
<li>Fewer eye candy.</li>
<li>Bottom-line: Check back in 6 months; the library is improving rapidly.</li>
</ul>
<li>Google Chart Tools: http://code.google.com/apis/chart</li>
<ul>
<li>Does not cost money but source code is not available and hard dependency on Google’s server.</li>
<li>Mature and well-documented.</li>
<li>Programming not as easy but powerful.</li>
<li>Better eye candy &#8212; see Geographic chart.</li>
<li>Bottom-line: Good solution but the charts and data security are heavily dependant on Google’s server.</li>
</ul>
<li>Highcharts: http://www.highcharts.com</li>
<ul>
<li>Costs money (couple of hundreds) but open source.</li>
<li>Mature; Good documentation.</li>
<li>Programming is easy.</li>
<li>Best eye candy &#8212; charts will “pop” to your users.</li>
<li>Bottom-line: Best overall general-purpose charting solution.</li>
</ul>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/12/choosing-web-chart-technologies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Staging servers</title>
		<link>http://blog.GORGES.us/2011/08/staging-servers/</link>
		<comments>http://blog.GORGES.us/2011/08/staging-servers/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 12:52:33 +0000</pubDate>
		<dc:creator>Matt Clark</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTAuth]]></category>
		<category><![CDATA[quality assurance]]></category>
		<category><![CDATA[staging servers]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=472</guid>
		<description><![CDATA[At GORGES we prefer to set up a staging server or website for our bigger projects.  I would even call it a requirement since it can be used by the customer and our quality assurance staff to review both progress and the release candidate before publishing a website to a production site. Usually developers work [...]]]></description>
			<content:encoded><![CDATA[<p>At GORGES we prefer to set up a staging server or website for our bigger projects.  I would even call it a requirement since it can be used by the customer and our quality assurance staff to review both progress and the release candidate before publishing a website to a production site.</p>
<p>Usually developers work directly on their workstations or laptops, and a development environment has both web and database services running similar to a production server. Ideally a development environment should have the same versions of services as the production server, for example PHP 5.2 or Ruby 1.9.  On more than one occasion I have been bitten by writing MySQL 4.3 or 5 code, but the production server has an older version of MySQL without sub-query support so the queries had to be rewritten.</p>
<p>Usually these development services are customized for development, for example the database does not have to be hardware-optimized and the web service can have debugging tools enabled.  I prefer to turn on all warning messages, so any identified problems that are not severe enough to halt page serving will be shown either in a log file or onscreen.</p>
<p>Just as important with having a staging server is to have clean and well-structured publishing scripts.  If you are relying on a manual process to upload files using FTP, then it is possible to skip an updated file by mistake.  Publishing scripts come in all sorts of flavors and approaches &#8211; we have both &#8220;pull&#8221; methods that use server-side scripts, and &#8220;push&#8221; scripts that execute on the developer&#8217;s computer and automatically upload files to the server.  The push scripts are built on Capistrano, which although it is based on ruby we sometimes use at Gorges for non-ruby websites.</p>
<p>We routinely protect our staging servers from prying eyes and search engines by using HTAuth username and passwords.  Once a website is scanned by a Google, Bing, or other web crawler then it is out of your control.</p>
<p>Having a staging server doesn&#8217;t mean much unless it is actually used to test new features and look for bugs.  Quality assurance is important, and I have yet to meet a developer that produces bug-free code or see a unit testing system that covers 100% of a web application feature set.</p>
<p>Not covered in this post is the issue of database migrations between developer environment and a staging server, and also from a staging server to a production machine.  These can be tricky, but as with all challenges the proper planning will guide you to the best solution.</p>
<p>After the application or update goes live to the production server most staging servers are continued as &#8220;sand boxes&#8221; to support additional updates and testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/08/staging-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast Custom Facebook Tabs for your Business Page</title>
		<link>http://blog.GORGES.us/2011/08/fast-custom-facebook-tabs-for-your-business-page/</link>
		<comments>http://blog.GORGES.us/2011/08/fast-custom-facebook-tabs-for-your-business-page/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 12:45:01 +0000</pubDate>
		<dc:creator>Alex Michaluk</dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=679</guid>
		<description><![CDATA[This year Facebook scrapped their markup language FBML and introduced iframe Tabs for pages.  Although there has been a lot of grumbling from the Facebook community, this is good news for web developers, as it allows them to work outside of Facebook in any framework once they&#8217;ve done a little bit of setup. Finding straightforward [...]]]></description>
			<content:encoded><![CDATA[<p>This year Facebook scrapped their markup language FBML and introduced iframe Tabs for pages.  Although there has been a lot of grumbling from the Facebook community, this is good news for web developers, as it allows them to work outside of Facebook in any framework once they&#8217;ve done a little bit of setup.</p>
<p>Finding straightforward explanation of how to immediately dive in proved to be a bit painful &#8211; most of the tutorials I found seemed to be aimed towards clients or casual Facebook users rather than developers. I thought I would compile the information I found useful in quickly making custom tabs for Facebook pages.</p>
<p>First of all, even though they still use the term tab, what we are talking about are the links in the left column that fall under Wall.  A standard first  custom tab to add is a Welcome tab.</p>
<p>I originally tried using an existing app (Static HTML frame tabs) which worked fine, but had two major disadvantages.  One was that you could not assign a custom icon, and the second that it could only be used to create one link.  This could be handy for a quick and easy custom welcome page, but most likely a client is going to want more than one custom tab.</p>
<p>I won&#8217;t cover signing up as a developer, but basically it involves creating a Facebook account and being assigned as an admin to an existing business page, or creating your own.  You will also need to be confirmed via a text to your mobile phone or by entering a credit card.</p>
<p>After you&#8217;ve done this, you can head on over to http://developers.facebook.com, and hit the <strong>Apps</strong> link, and then the <strong>+ Create New App</strong> button:</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/1.png"><img class="alignnone size-full wp-image-680" src="http://blog.GORGES.us/wp-content/uploads/2011/08/1.png" alt="" width="334" height="86" /></a></p>
<p>Create a name for the app:</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/2.png"><img class="alignnone size-full wp-image-681" src="http://blog.GORGES.us/wp-content/uploads/2011/08/2.png" alt="" width="500" height="190" /></a></p>
<p>This will create an app with an app ID (which you will need later).</p>
<p>For now, you can just upload a 16&#215;16 icon that you would like to appear to the left of the link on your page.</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/3.png"><img class="alignnone size-full wp-image-682" src="http://blog.GORGES.us/wp-content/uploads/2011/08/3.png" alt="" width="868" height="398" /></a></p>
<p>Now, click the <strong>On Facebook</strong> link in the left column.</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/3.5.png"><img class="alignnone size-full wp-image-683" src="http://blog.GORGES.us/wp-content/uploads/2011/08/3.5.png" alt="" width="192" height="196" /></a></p>
<p>Enter the <strong>Tab Name</strong> (This is the name of the link as it will appear on your page) and the <strong>Tab Url</strong>.</p>
<p>The Tab Url is a link to a file hosted somewhere else that will be placed in the iframe (more on constructing this later)</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/4.png"><img class="alignnone size-full wp-image-684" src="http://blog.GORGES.us/wp-content/uploads/2011/08/4.png" alt="" width="672" height="148" /></a></p>
<p>After saving, click <strong>View App Profile Page</strong> in the left column</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/5.png"><img class="alignnone size-full wp-image-685" src="http://blog.GORGES.us/wp-content/uploads/2011/08/5.png" alt="" width="186" height="382" /></a></p>
<p>Now you can click <strong>Add to My Page</strong> , and then select the page (for which you are already an admin) that you wish to add it to.</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/6.png"><img class="alignnone size-full wp-image-686" src="http://blog.GORGES.us/wp-content/uploads/2011/08/6.png" alt="" width="663" height="194" /></a></p>
<p>Now, if you navigate to the page you&#8217;ve added it to, you will see it as a tab in the left column:</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/7.png"><img class="alignnone size-full wp-image-687" src="http://blog.GORGES.us/wp-content/uploads/2011/08/7.png" alt="" width="180" height="420" /><br />
</a></p>
<p>Hit the <strong>Edit</strong> button below the tabs to rearrange the tabs, but note that Wall and Info will always come first.</p>
<p>To make this new tab the default landing page of your site, click <strong>Edit Info</strong> at the top of your page.</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/8.png"><img class="alignnone size-full wp-image-688" src="http://blog.GORGES.us/wp-content/uploads/2011/08/8.png" alt="" width="482" height="109" /></a></p>
<p>Now click <strong>Manage Permissions</strong> and then choose the <strong>Default Landing Tab </strong>from the dropdown.  Note that fans and admins of the page will always be directed to the wall &#8211; this default landing page only applies to anonymous users or non-fans.</p>
<p><a href="http://blog.GORGES.us/wp-content/uploads/2011/08/9.png"><img class="alignnone size-full wp-image-689" src="http://blog.GORGES.us/wp-content/uploads/2011/08/9.png" alt="" width="550" height="244" /></a></p>
<p>Finally, a note on creating your content for the iframe. I initially ran into some problems with scrollbars appearing both vertically and horizontally in the frame &#8211; the solution was to include two Facebook scripts and apply a little bit of css, all of which you can see in the basic template below. You&#8217;ll need to modify the height, add your content, and also include your app id in the bottom script.</p>
<blockquote><p>&lt;!DOCTYPE html&gt;&lt;html&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;title&gt;&lt;/title&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;window.fbAsyncInit = function() {FB.Canvas.setSize();}function sizeChangeCallback() {FB.Canvas.setSize();}&lt;/script&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body style=&#8221;width:520px;overflow:hidden;&#8221;&gt;</p>
<p><strong>&lt;!&#8211; Modify height if necessary &#8211;&gt;</strong></p>
<p>&lt;div style=&#8221;width:520px;height:1000px;overflow:hidden;&#8221;&gt;</p>
<p><strong>&lt;!&#8211;Your Content Here &#8211;&gt;</strong></p>
<p>&lt;/div&gt;</p>
<p>&lt;div id=&#8221;fb-root&#8221;&gt;&lt;/div&gt;</p>
<p>&lt;script src=&#8221;http://connect.facebook.net/en_US/all.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script&gt;</p>
<p>FB.init({</p>
<p><strong>// CHANGE THIS TO YOUR APP ID</strong></p>
<p>appId : &#8217;123456789&#8242;,</p>
<p>status : true,</p>
<p>cookie : true,</p>
<p>xfbml : true</p>
<p>});</p>
<p>&lt;/script&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>That&#8217;s all you need to do.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/08/fast-custom-facebook-tabs-for-your-business-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery DOM shortcuts</title>
		<link>http://blog.GORGES.us/2011/06/jquery-dom-shortcuts/</link>
		<comments>http://blog.GORGES.us/2011/06/jquery-dom-shortcuts/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 13:29:16 +0000</pubDate>
		<dc:creator>Rasmus Schultz</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=656</guid>
		<description><![CDATA[Working daily with jQuery, at GORGES I frequently need to construct little document snippets and forms on the fly. Today I came up with a quick little meta-programming &#8220;hack&#8221; that makes this very easy and fast. Most people simply do something along the lines of this: jQuery injects the HTML string into the DOM, and [...]]]></description>
			<content:encoded><![CDATA[<p>Working daily with <a href="http://jquery.com/">jQuery</a>, at GORGES I frequently need to construct little document snippets and forms on the fly. Today I came up with a quick little meta-programming &#8220;hack&#8221; that makes this very easy and fast.</p>
<p>Most people simply do something along the lines of this:</p>
<pre class="brush: plain; title: ; notranslate">
$('body').append('&lt;h1&gt;Hello, World&lt;/h1&gt;');
</pre>
<p>jQuery injects the HTML string into the DOM, and all is well.</p>
<p>But sometimes you need to inject more structured content, or even entire forms &#8211; what I typically do is something along the lines of this:</p>
<pre class="brush: plain; title: ; notranslate">
jQuery('body').append(
  $('&lt;div/&gt;').append(
    $('&lt;div/&gt;').text('Hi there'),
    $('&lt;p/&gt;').text('How do you do?')
  )
);
</pre>
<p>With all the parentheses, angle brackets and repetitive calls to append(), this doesn&#8217;t exactly look nice.</p>
<p>Recognizing the repetitive construction of elements, followed by calls to append, what if we had a set of tiny functions that would do both in one simple operation? I decided to give it a shot, and here&#8217;s what it looks like:</p>
<pre class="brush: plain; title: ; notranslate">
jQuery('body').append(
  $div(
    $h2('Do you love it?'),
    $form(
      $div('Sign here:', $text()),
      $div($label($checkbox('yes'), 'I love it!')),
      $ul(
        $li($radio('1'), 'Option One'),
        $li($radio('2'), 'Option Two'),
        $li($radio('3'), 'Option Three')
      ),
      $submit('I submit!')
    )
  )
);
</pre>
<p>The functions prefixed with the $-sign create the elements, and pass down any arguments to the append() method.</p>
<p>The input element methods, such as $radio and $submit are a bit different &#8211; they create input elements, set the type-attribute, and if you pass them an argument, they apply that as the value-attribute on the element. (input elements can&#8217;t have child-elements, so this doesn&#8217;t get in the way of anything.)</p>
<p>You can see a <a href="http://jsfiddle.net/mindplay/TufsA/">working example and source code here</a>.</p>
<p>Because JavaScript is a highly dynamic language, I didn&#8217;t need to write each of these $-functions by hand &#8211; with just 13 lines of JavaScript, applying a simple meta-programming technique, all of the functions are automatically generated.</p>
<p>Finally, it&#8217;s worth noting that something like <code>$('&lt;div/&gt;')</code> actually results in a string of HTML being parsed and then inserted into the browser. My handy little DOM-helpers avoid the parser &#8211; they access the DOM and create HTML elements directly, which means they execute around <a href="http://stackoverflow.com/questions/327047/what-is-the-most-efficient-way-to-create-html-elements-using-jquery/327065#327065">10 times faster</a> compared to the first example.</p>
<h4>Update</h4>
<p>One of my GORGES colleagues pointed out the fact that I had no convenient way to apply attributes to the created elements &#8211; if you don&#8217;t like the repetitive calls to attr(), <a href="http://jsfiddle.net/mindplay/N8cme/">try this updated version</a>, which provides a simplified way to apply attributes quickly. This takes a bit more code, but I suspect he&#8217;s now porting this to CoffeeScript</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/06/jquery-dom-shortcuts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript Unit Testing</title>
		<link>http://blog.GORGES.us/2011/05/javascript-unit-testing/</link>
		<comments>http://blog.GORGES.us/2011/05/javascript-unit-testing/#comments</comments>
		<pubDate>Mon, 16 May 2011 12:20:50 +0000</pubDate>
		<dc:creator>Jim Tse</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JS Test Driver]]></category>
		<category><![CDATA[QUnit]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=626</guid>
		<description><![CDATA[As recently blogged on GORGES, unit testing is important to the success of projects. Unit testing reduces bugs, improves a project&#8217;s robustness to requirement changes, and sustains a high rate of programming productivity. It is well-accepted that most if not all, non-trivial web applications should include unit tests as part of the project specification. Web [...]]]></description>
			<content:encoded><![CDATA[<p>As recently blogged on GORGES, <a href="http://blog.gorges.us/2011/03/unit-testing-a-key-part-of-web-development-best-practices/">unit testing is important to the success of projects</a>. Unit testing reduces bugs, improves a project&#8217;s robustness to requirement changes, and sustains a high rate of programming productivity. It is well-accepted that most if not all, non-trivial web applications should include unit tests as part of the project specification.</p>
<p>Web developers typically write unit tests on server side code and rarely on client side code, which is where JavaScript resides. This approach is reasonable given that the majority of the application logic of web applications run on the server side. However, as the web become increasingly more dynamic, so does the number of lines of JavaScript code needed to support a rich user experience. The need for unit testing in JavaScript should be apparent, yet JavaScript unit testing have been largely ignore.</p>
<p>One reason why developers don&#8217;t write JavaScript unit tests is that JavaScript testing is front end testing. Front end tests are hard to write and we are better off leaving it to manual testers. Keep in mind, however, that application logic tend grow exponentially in complexity. So unless the project has the resources to hire manual testers at an exponential rate, it is far more cost effective to devote the time to write tests.</p>
<p>Another reason for not writing JavaScript unit tests is the belief that client side programming logic should be minimized and pushed into the server side wherever possible. The rationale is that JavaScript unit testing is not needed if the code base is small. In other words, not writing JavaScript means not having to write unit tests. However, as mentioned, JavaScript is needed to support a rich web experience. Not writing JavaScript is not an option if a modern web experience is desired.</p>
<p>There are many free and open source testing frameworks available for JavaScript. Three such frameworks are: Selenium, JS Test Driver, and QUnit.</p>
<p><strong>SELENIUM</strong>, <a href="http://seleniumhq.com">http://seleniumhq.com</a></p>
<p>Selenium is not a JavaScript testing framework. Rather, it is an end-to-end testing framework for web applications. So Selenium implicitly tests the JavaScript portions of a web application. Selenium works as follows:</p>
<ol>
<li>Write your Selenium scripts. The scripts can be written in many languages including PHP, Ruby, C#, and Java. If you don&#8217;t know how to program, you can use Selenium IDE which is a Firefox plugin that records your mouse clicks and typing web browsing behavior to create test scripts</li>
<li>Your unit test runner (e.g., JUnit) sends the scripts to the Selenium server</li>
<li>The Selenium server launches browsers and runs the tests. The Selenium server can be configured to launch different browsers on different computer platforms (e.g., PC, Mac, Linux).</li>
</ol>
<p>Note that Selenium runs your tests using real browsers so you get comprehensive tests of your web application against various browsers. The downside is that the comprehensiveness also leads to complexity of setting up the Selenium server and stand-by machines waiting for Selenium tests. Selenium is best suitable for large web projects with the resources needed to configure various servers.</p>
<p><strong>JS TEST DRIVER</strong>, <a href="http://code.google.com/p/js-test-driver/">http://code.google.com/p/js-test-driver/</a></p>
<p>JS Test Driver can be thought of as Selenium-lite but specifically designed for unit testing your JavaScript code (as opposed to end-to-end integration testing as is the case with Selenium). The test runner for JS Test Driver runs your unit tests in the same manner as Selenium. JS Test Driver launches your browsers and executes your tests inside the browser. JS Test Driver can also be integrated into the Eclipse or IntelliJ IDE as a plugin which provides a one click interface to running your JavaScript tests.</p>
<p><strong>QUnit</strong>, <a href="http://docs.jquery.com/Qunit">http://docs.jquery.com/Qunit</a></p>
<p>QUnit is the simplest of the three framework. You write your tests in JavaScript and embed it in an HTML page with qunit.js and qunit.css include. To run your tests, you simply refresh the page in your browser. There is almost no learning curve for developers familiar with any of the xUnit framework. Because of its simplicity, there is no out-of-the-box support for running your tests on multiples browsers simultaneously, unlike Selenium and JS Test Driver.</p>
<p><strong>Which framework?</strong></p>
<p>These three frameworks all serve different testing needs and are by no means mutually exclusive. If you are only interested in end-to-end integration test, then Selenium is a good choice if you have the resources to set up your testing environment. If you see the value of unit testing JavaScript in your web application, then QUnit is the easiest way to start but look into JS Test Driver as your testing need evolves.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/05/javascript-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Our Favorite Wireframing Tools</title>
		<link>http://blog.GORGES.us/2011/05/our-favorite-wireframing-tools/</link>
		<comments>http://blog.GORGES.us/2011/05/our-favorite-wireframing-tools/#comments</comments>
		<pubDate>Mon, 16 May 2011 12:18:58 +0000</pubDate>
		<dc:creator>Don Ellis</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[User Interface UX]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=630</guid>
		<description><![CDATA[Experience shows us that taking the time to plan a software project well, even if it is a small website, is time worth spending. Chaos and miscommunication are the expensive parts of projects. Planning reduces them radically. There are several steps in planning. Needs Assessment Platform Analysis Information Analysis Wireframing Prototyping Work and Phase Planning [...]]]></description>
			<content:encoded><![CDATA[<p>Experience shows us that taking the time to plan a software project well, even if it is a small website, is time worth spending. Chaos and miscommunication are the expensive parts of projects. Planning reduces them radically.</p>
<p>There are several steps in planning.</p>
<ul>
<li>Needs Assessment</li>
<li>Platform Analysis</li>
<li>Information Analysis</li>
<li>Wireframing</li>
<li>Prototyping</li>
<li>Work and Phase Planning</li>
<li>Budget Planning</li>
</ul>
<p>All of these save money and improve the quality of the product. As consultants we also know that involvement and review with the client is a critical part of each planning step.</p>
<p>One of my favorite steps is wireframing because this is where the idea first takes graphic form. There are many small apps for making wireframes.</p>
<p>The wireframing tools that we have used within our office, here are some we like:</p>
<p><strong>Eclipse with a Wireframe Sketcher plug-in</strong> ($75 or $37.50 for students).  We have a GORGES license, and there is a downloadable standalone version available (<a href="http://wireframesketcher.com">http://wireframesketcher.com</a>).  You can probably try before buying.</p>
<p><strong>Omnigraffle Pro</strong> (Mac-only application).  We have an office license, but since it is Mac-only only a few developers use it here.</p>
<p><strong>Pencil</strong> (free Firefox Browser plug-in, <a href="http://pencil.evolus.vn">http://pencil.evolus.vn</a>).  Feature-limited and sometimes awkward, but the price is right.</p>
<p><strong>Balsamiq</strong> – online version; useful for working remotely.  We used this a few years back when it was in free beta stage.  <a href="http://www.balsamiq.com">http://www.balsamiq.com</a>.</p>
<p><strong>Microsoft Visio</strong> – my least-favorite tool because of cost and clunkiness, but perhaps the leading prototyping tool thanks to Microsoft’s influence.  <a href="http://office.microsoft.com/en-us/visio/">http://office.microsoft.com/en-us/visio/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/05/our-favorite-wireframing-tools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why You Should Use CoffeeScript</title>
		<link>http://blog.GORGES.us/2011/05/why-you-should-use-coffeescript/</link>
		<comments>http://blog.GORGES.us/2011/05/why-you-should-use-coffeescript/#comments</comments>
		<pubDate>Mon, 16 May 2011 11:59:02 +0000</pubDate>
		<dc:creator>David Furber</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[User Interface UX]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website Design]]></category>
		<category><![CDATA[CoffeeScript]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=632</guid>
		<description><![CDATA[JavaScript (JS) is the programming language that allows web developers to make web pages interactive. Each browser has a slightly different implementation, which developers iron out by using cross-browser frameworks such as JQuery. It doesn&#8217;t matter if the server side component is written in PHP or Ruby &#8211; the front end is always JavaScript. Thanks [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript (JS) is the programming language that allows web developers to make web pages interactive. Each browser has a slightly different implementation, which developers iron out by using cross-browser frameworks such as JQuery. It doesn&#8217;t matter if the server side component is written in PHP or Ruby &#8211; the front end is always JavaScript. Thanks to Google&#8217;s V8 JavaScript engine and Node.js, JS is also becoming the goto language for realtime interactive web applications such as chat, live blogs. JS is the language behind most everything the end user perceives as cool in the UI.</p>
<p>JS has been around since the late 1990s. Like a house with several owners with different tastes, it&#8217;s been added on to over the years. It&#8217;s really easy to write ugly JS, chock full of bugs, that no other developer will ever want to or be able to read. You can accidentally open memory leaks that crash the browser. You can accidentally put a variable in the global namespace and cause the rest of the program to come to a crashing halt, or behave mysteriously.</p>
<p>At the same time, the core of JS is a beautiful language that, if you stick to the &#8220;good parts,&#8221; can support the richest of rich client apps with grace and aplomb. That is where CoffeeScript comes in.</p>
<p>CoffeeScript (CS) is a language that compiles into JavaScript. It makes it easier and less tedious to do good things with JS, and harder to do bad things. Because CS only turns into JS when the i&#8217;s are dotted and the t&#8217;s are crossed, it is harder to write buggy JS.</p>
<h3>Line Noise Reduction</h3>
<p>Programming languages based on C or Java, such as JS and PHP, are filled with parentheses and semicolons to tell the computer where each block of code starts and ends. Keywords such as &#8220;var&#8221; and &#8220;function&#8221; tell the computer which are variables and which are functions. The programmer&#8217;s eye gets used to them, and may even come to rely on them to interpret code on the screen.</p>
<p>Oftentimes before I write a paper I begin with an outline. Top level items are on the left, and each layer of sub-item gets one level of indentation. My word processor responds when I press the TAB key, and has an indent button. There is no facility to write an outline like the following, nor is there a word processing facility for doing so outside of a code editor:</p>
<pre class="brush: plain; title: ; notranslate">I. The Industrial Revolution {
    A. Origins {
        i. deforestation in 17th century England
        ii. proximity of coal and iron deposits
        iii. accumulation of capital from overseas trade
    }
}</pre>
<p>Therefore if you want to make code more human readable, replace the braces with indentation, and let the compiler put them back in for you to make the computer happy. CS does this, calling it &#8220;syntactic white-space&#8221;:</p>
<pre class="brush: jscript; title: ; notranslate">class App
  ...
  initUI: -&gt;
    if $('#controls').size() is 0
      $('#title').append render('searchControls')
      JKT.earth.addControls() if (JKT.earth)
    ...
</pre>
<p>becomes:</p>
<pre class="brush: jscript; title: ; notranslate">App = (function() {
  function App() {
    ...
  }
  App.prototype.initUI = function() {
    if ($('#controls').size() === 0) {
      $('#title').append(render('searchControls'));
      if (JKT.earth) {
        JKT.earth.addControls();
      }
    }
  }
  return App;
});
</pre>
<p>I personally find the CS more meaningful, and the compiled code to be cleaner than the code I would have written to do the same thing (although it&#8217;s not fashionable to admit that your code isn&#8217;t always the cleanest and most awesome code anyone has ever written).</p>
<p>Notice that the -&gt; stands for &#8220;function&#8221;, and function name colon: means &#8220;add this function to the object prototype.&#8221; Please read the CS documentation a few times before you try CS &#8211; this is just the beginning of the stuff you can do.</p>
<p>The bottom line is that &#8220;line noise reduction&#8221; removes as much computer-oriented meaning as possible from the code, while leaving the human-oriented meaning. The principle is that while programmers write code for computers to run, unless it&#8217;s one-time only throwaway code, they&#8217;re also writing code for other programmers (including themselves when they come back to it three months later to add a new feature). The less time it takes a programmer to figure out what is going on, the higher the business value.</p>
<h3>Meaningful Code is Cleaner Code</h3>
<p>The code snippet above isn&#8217;t necessarily fair, because it doesn&#8217;t show JS &#8220;before I started writing CS.&#8221; I see that it has benefited from the other thing I most like about CS: to make it easier to debug, you have to break it down into smaller parts. Smaller parts that do one thing only are cleaner parts.</p>
<p>That&#8217;s right. In the old regime, I might have a JS file with several hundred lines. When a error pops up, Firebug will tell me what line it&#8217;s on, and I can jump to it in the code editor and fix it. Maybe right there I will add some more code, and pretty soon I&#8217;ll have a large JS file that is hard to edit without Firebug, with lots of interconnected parts and mixed behaviors.</p>
<p>Since CS makes working with the JS object model so easy, I find myself using it. I would take that 500 line JS file and break it into a half dozen or more constituent parts. I have development mode set to deliver these to the browser individually, so if an error crops up, it&#8217;s easier for me to find it in the CS. Production mode combines and minifies the JS into one file for speed of delivery to the user.</p>
<p>If you&#8217;re coming from Ruby or Python, you&#8217;ll recognize the philosophy of human oriented code. You&#8217;ll also recognize that CS is 2/3 Python and 1/3 Ruby. Therefore CS will be easier for you if you know one of those; likewise if you hate Ruby, stay away from CS. (And if you don&#8217;t know JS yet, don&#8217;t try CS&#8230;)</p>
<h3>Gotchas</h3>
<p>I must admit that CS came with some pounding of my head on the table, especially when I started. Here&#8217;s where I got stuck, and what I did to get unstuck:</p>
<ol>
<li>I started by opening a JS file and &#8220;saving as&#8221; a coffee file. DON&#8217;T DO THAT! Create a new coffee file, copy the JS from the JS file, and paste it into the coffee file. The paste action will get the indentation right.</li>
<li>Your code may look indented to you, but it may not be so for coffee. You may have SPACES mixed in with your TABS.</li>
</ol>
<p>When you make changes to coffee but nothing seems to happen in the browser:</p>
<ol>
<li>First check that you are running the compiler. I have a shell script that starts coffee&#8217;s compile-on-edit mode. Sometimes I forget to run it. By the third alert statement, I check for that.</li>
<li>Second, check the compiler output. You may have a syntax error in CS. It won&#8217;t compile at all if there&#8217;s a problem with the CS. If you see &#8220;cannot use a pure statement in an expression&#8221;, it usually means there&#8217;s a rogue space in your tab indentation. Redo the indentation and try again.</li>
<li>Third, if the CS compiled but weird things are happening such as it says a function doesn&#8217;t exist when you know it does, check the compiled JS. Sometimes there is an indentation issue that doesn&#8217;t break the compiler, but causes it to misinterpret where classes end and begin.</li>
</ol>
<h3>In a perfect world</h3>
<p>CS is new. Therefore it is not integrated into most IDEs yet. Since Rails 3.1 uses CoffeeScript, it shouldn&#8217;t be long before you see CS support in Aptana. There is an IntelliJ plugin for RubyMine and PHPStorm. I use the TextMate bundle. My colleague <a href="http://www.GORGES.us/team_jtse">Jim</a> uses Eclipse and edits it with plain text, as he finds it still easier to read than JS.</p>
<h3>Getting started</h3>
<p>I recommend going to the CS website (<a href="http://jashkenas.github.com/coffee-script/">http://jashkenas.github.com/coffee-script/</a>). Read it a few times before you do anything. Bookmark it. Then install node, npm, and coffee.</p>
<p>When I started on CS, I had a few thousand lines of JS already written. Most of it was for a prototype, and I dreaded having to whip it into production grade and add the rest of the features to it. I started learning CS by porting some of the easier JS files. When I was comfortable, I took on the hairy part. It emerged as a piece of code I&#8217;m proud of and like to work with.</p>
<p>In a nutshell, CoffeeScript makes it fun for me to write clean JavaScript, and delivers business value by helping me to write maintainable JavaScript faster that it otherwise would. If you&#8217;re not using it yet, it&#8217;s time to start.</p>
<h3>References/Additional Resources</h3>
<ol>
<li>The CoffeeScript web page: <a href="http://jashkenas.github.com/coffee-script/">http://jashkenas.github.com/coffee-script/</a></li>
<li>My presentation to the Ithaca Web Group: <a href="http://www.slideshare.net/davidfurber/real-lifecoffeescript">http://www.slideshare.net/davidfurber/real-lifecoffeescript</a></li>
<li>Tongue in cheek presentation of why you&#8217;ll hate CS: <a href="http://www.slideshare.net/tim.lossen.de/coffeescript-7-reasons-you-are-gonna-hate-it">http://www.slideshare.net/tim.lossen.de/coffeescript-7-reasons-you-are-gonna-hate-it</a></li>
<li><a href="http://peepcode.com/products/coffeescript">The PeepCode screencast, &#8220;Meet CoffeeScript&#8221;</a></li>
<li><a href="http://pragprog.com/titles/tbcoffee/coffeescript">The PragProg book (written by yours truly), &#8220;CoffeeScript: Accelerated JavaScript Development&#8221;</a></li>
<li><a href="http://coffeescriptcookbook.com/">The CoffeeScript Cookbook wiki (new, but promising)</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/05/why-you-should-use-coffeescript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HAML Basics</title>
		<link>http://blog.GORGES.us/2011/04/haml-basics/</link>
		<comments>http://blog.GORGES.us/2011/04/haml-basics/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 11:52:50 +0000</pubDate>
		<dc:creator>Alex Michaluk</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HAML]]></category>

		<guid isPermaLink="false">http://blog.GORGES.us/?p=555</guid>
		<description><![CDATA[HAML (HTML Abstraction Markup Language) is a template engine responsible for addressing many of the flaws in traditional markup. HAML is Whitespace Active, DRY, follows CSS Conventions, and integrates Ruby or PHP code. Its results in very clean and elegant markup. I will be focusing on the Ruby implementation in this posting, but note that [...]]]></description>
			<content:encoded><![CDATA[<p>HAML (HTML Abstraction Markup Language) is a template engine responsible for addressing many of the flaws in traditional markup. HAML is Whitespace Active, DRY, follows CSS Conventions, and integrates Ruby or PHP code. Its results in very clean and elegant markup.</p>
<p>I will be focusing on the Ruby implementation in this posting, but note that there are also implementations for PHP, .NET, Java, and several other languages. As you might expect with Ruby, HAML is installed as a gem, and once installed, all .erb files can be renamed .HAML to be run through the HAML compiler.</p>
<p>When using HAML, tags are marked with the % symbol. For example:</p>
<pre class="brush: xml; title: ; notranslate">%strong hello</pre>
<p>This would be compiled to:</p>
<pre class="brush: xml; title: ; notranslate">&lt;strong&gt;hello&lt;strong&gt;</pre>
<p>Although you could write:</p>
<pre class="brush: xml; title: ; notranslate">%div hello</pre>
<p>to create a div, it is not necessary as HAML makes the common div tag the default. It also borrows the period symbol from CSS to denote class, so the following:</p>
<pre class="brush: xml; title: ; notranslate">.content Hi</pre>
<p>would be compiled to:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div class='content'&gt;&lt;/div&gt;</pre>
<p>Classes can also be chained, so the following:</p>
<pre class="brush: xml; title: ; notranslate">.content.notice Bye</pre>
<p>would be compiled to:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div class='content notice'&gt;Bye&lt;/div&gt;</pre>
<p>HAML is whitespace active, so we can nest divs as follows:</p>
<pre class="brush: xml; title: ; notranslate">
#parent
  #child
    #grandchild
      #brother-twin I am the evil twin
      #sister-twin I am the good twin
</pre>
<p>to create:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;parent&quot;&gt;
  &lt;div id=&quot;child&quot;&gt;
    &lt;div id=&quot;grandchild&quot;&gt;
      &lt;div id=&quot;brother-twin&quot;&gt;I am the evil twin&lt;/div&gt;
      &lt;div id=&quot;sister-twin&quot;&gt; I am the good twin&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Comments are also more legible in HAML:</p>
<pre class="brush: xml; title: ; notranslate">/ here is a comment</pre>
<p>would generate the bulkier:</p>
<pre class="brush: xml; title: ; notranslate">&lt;!-- here is a comment --&gt;</pre>
<p>HAML includes filters which are denoted by a colon, and some examples are</p>
<pre class="brush: xml; title: ; notranslate">
:plain
:javascript
:markdown
</pre>
<p>You can also create your own. Usage is simple:</p>
<pre class="brush: xml; title: ; notranslate">
#content
  :markdown
    Some *emphasis*</pre>
<p>would compile to:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;content&quot;&gt;
  &lt;p&gt;Some &lt;em&gt;emphasis&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>Including Ruby (or other) code is either silent with the dash symbol, or inline with the equals symbol.</p>
<pre class="brush: xml; title: ; notranslate">
#content
  .title
    %h1=@title
</pre>
<p>would create:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;content&quot;&gt;
  &lt;div class=&quot;title&quot;&gt;
    &lt;h1&gt;My Page&lt;/h1&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>One of my favorites is the Object Reference, which uses square brackets with an object. Basically, given an object, it will work as div_for and content_for in Ruby, generating a id and class name based on the id and class of the given object. This is very handy for use with javascript and jquery and really polishes the markup.</p>
<pre class="brush: xml; title: ; notranslate">
%div[monster]
  %ul.eyeballs
    -monster.eyeballs.each do |eyeball|
      %li[eyeball]
        =eyeball.color
</pre>
<pre>would create:
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;monster_4&quot;&gt;
  &lt;ul&gt;
    &lt;li id=&quot;eyeball_1&quot;&gt;Green&lt;/li&gt;
    &lt;li id=&quot;eyeball_2&quot;&gt;Blue&lt;/li&gt;
    &lt;li id=&quot;eyeball_3&quot;&gt;Grey&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.GORGES.us/2011/04/haml-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

