<?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>Meta Bates &#187; erb</title>
	<atom:link href="http://www.metabates.com/tag/erb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.metabates.com</link>
	<description>The technical ramblings of Mark Bates.</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:25:34 +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>Because everybody has an opinion&#8230;</title>
		<link>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/</link>
		<comments>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 01:30:20 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[coffee script]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.metabates.com/?p=430</guid>
		<description><![CDATA[In case you&#8217;ve been living in a cave this week you&#8217;ve probably heard that Ruby on Rails is going to be including both the CoffeeScript and SASS libraries, it will also make jQuery the default JavaScript framework, replacing the Prototype framework. I would like to start by addressing my experiences with CoffeeScript. My opinion of [...]]]></description>
			<content:encoded><![CDATA[<p>In case you&#8217;ve been living in a cave this week you&#8217;ve probably heard that <a href="http://www.rubyinside.com/rails-3-1-adopts-coffeescript-jquery-sass-and-controversy-4669.html">Ruby on Rails</a> is going to be including both the <a href="http://coffeescript.org/">CoffeeScript</a> and <a href="http://sass-lang.com/">SASS</a> libraries, it will also make <a href="http://jquery.com/">jQuery</a> the default JavaScript framework, replacing the <a href="http://www.prototypejs.org/">Prototype</a> framework.</p>
<p>I would like to start by addressing my experiences with CoffeeScript. My opinion of it is of ambivalence. I&#8217;ve used it on a project, I&#8217;ve played with and in the end I&#8217;ve come out with the opinion of &#8220;it&#8217;s ok&#8221;. It didn&#8217;t blow me away, but at the same time I can see why so many people like. It offers some really cool features that I really wish JavaScript had and you can cut down on the amount of code you have to write. On the other hand the apps I tend to write don&#8217;t tend to be that JavaScript heavy that I really needed to reach out for something like CoffeeScript.</p>
<p><img class="alignleft" src="http://blogs.worldbank.org/files/publicsphere/public%20opinion_JGRNLY.jpeg" alt="" width="326" height="246" />So, how do I feel about CoffeeScript being included with Rails? Well, I&#8217;ll get to that. Let&#8217;s go over some of the most common arguments I&#8217;ve heard from people this week about why they&#8217;re anti-CoffeeScript in Rails.</p>
<blockquote><p>&#8220;It&#8217;s an abstraction layer of JavaScript! JavaScript isn&#8217;t that bad, why can&#8217;t you just write JavaScript?&#8221;</p>
<p>&#8220;It&#8217;s going to be a hinderance to newbies. It&#8217;ll be too much of a learning curve!&#8221;</p></blockquote>
<p>Let&#8217;s start with that second point first, shall we? I agree, it does represent a new element that needs to be learned when coming to Rails. But here&#8217;s the pretty nifty thing about how it&#8217;s all implemented in Rails. In order to actually use CoffeeScript in Rails you have to create your files named foo.js.coffee if, however, you just name your file foo.js then, guess what? You will have to write plain old JavaScript! Seems like newbies, and those who don&#8217;t like CoffeeScript, can just keep writing plain old JavaScript without anything stopping them at all.</p>
<p>Now, let&#8217;s talk about the abstraction layer argument. Yes, CoffeeScript is an abstraction on top of JavaScript, but let&#8217;s take a look at a few other parts of the Rails stack and see how they hold up against this argument.</p>
<p>Here&#8217;s a fairly common Rails stack:</p>
<ul>
<li>ActiveRecord</li>
<li>Haml</li>
<li>jQuery</li>
<li>RSpec</li>
</ul>
<p>What do all those things have in common? Well, they&#8217;re all abstraction layers that sit on top of something else, don&#8217;t they? Let&#8217;s look at that list again?</p>
<ul>
<li>ActiveRecord &#8211; SQL (Structured Query Language)</li>
<li>Haml &#8211; HTML</li>
<li>jQuery &#8211; JavaScript, you could just as easily hand roll those AJAX calls in pure JavaScript.</li>
<li>RSpec &#8211; Test/Unit</li>
</ul>
<p>What I&#8217;ve found funny about the particular argument is that I&#8217;ve heard it MOST from those who use things like HAML, which is a DEFINITELY an abstraction layer that sits on top of HTML. See where I&#8217;m going with this one? Good, I don&#8217;t want to belabor the point. <img src='http://www.metabates.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, finally, where do I stand on this whole thing? Well, I view like it Test/Unit and Prototype. Those are both the current standard (although jQuery will replace Prototype in 3.1) and I don&#8217;t like or use either of them. Instead I configure Rails to use jQuery and RSpec. I don&#8217;t like Haml, but those that do simply replace ERB with Haml and they move on with their day. So my take is this, it&#8217;s there, it&#8217;s included. Use it if you like, or don&#8217;t. Is it really that big a deal? No, it really isn&#8217;t. If Rails dropped ERB and went with Haml as the default, would I bitch and moan, probably a bit, but then I&#8217;d just install the Rails-ERB gem and move on with my day, just like I do with jQuery and RSpec today.</p>
<p>So sit back, relax, use the libraries that you want to use, Rails let&#8217;s you do that. Oh, while you&#8217;re relaxing why not try out CoffeeScript, who knows, you might just enjoy it. Or not.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2011/04/15/because-everybody-has-an-opinion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preview (0.5.5): The New Rendering Engine</title>
		<link>http://www.metabates.com/2008/05/20/the-new-rendering-engine/</link>
		<comments>http://www.metabates.com/2008/05/20/the-new-rendering-engine/#comments</comments>
		<pubDate>Tue, 20 May 2008 20:12:32 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[erubis]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[mack]]></category>
		<category><![CDATA[markaby]]></category>
		<category><![CDATA[rendering]]></category>

		<guid isPermaLink="false">http://www.mackframework.com/?p=97</guid>
		<description><![CDATA[In the latest version of Mack the rendering engine has been completely re-written from the ground up. With this comes some new features, some incompatibility, and most importantly,Â extensibility. Let&#8217;s jump on in and see what we can expect with this release. Incompatibility Gone is &#60;%= @content_for_layout %&#62; in layouts. In is &#60;%= yield_to :view %&#62;. [...]]]></description>
			<content:encoded><![CDATA[<p>In the latest version of Mack the rendering engine has been completely re-written from the ground up. With this comes some new features, some incompatibility, and most importantly,Â extensibility. Let&#8217;s jump on in and see what we can expect with this release.</p>
<h3>Incompatibility</h3>
<ul>
<li>Gone is &lt;%= @content_for_layout %&gt; in layouts. In is &lt;%= yield_to :view %&gt;.</li>
<li>Gone is render(options_hash) in controllers/views. In is render(type, value, options_hash)<br />
Examples:<br />
render(:action =&gt; :new) is now render(:action, :new)<br />
render(:url =&gt; &#8220;http://www.mackframework.com&#8221;, :parameters =&gt; {:message =&gt; &#8220;hi&#8221;}) is nowÂ render(:url, &#8220;http://www.mackframework.com&#8221;, :parameters =&gt; {:message =&gt; &#8220;hi&#8221;})</li>
<li>Gone is *.xml.erb. In is *.xml.builder</li>
</ul>
<div>Let&#8217;s quickly talk about how theseÂ incompatibilitiesÂ have come about. First there were several bugs that needed to be addressed with the rendering engine. For example, if you set an instance variable in a view, it wasn&#8217;t available in the layout. That&#8217;s a pain if you want to do things like programatically set the page title. There were also &#8216;hacks&#8217; used to do things like render xml using the Builder::XmlMarkup library. It wasn&#8217;t clean, but it worked. Finally, the rendering engine itself wasn&#8217;t that extensible. All of that has now changed.</div>
<div></div>
<h3>Render Me Softly</h3>
<p>In the new rendering engine there are two parts to the system, Mack::Rendering::Type::* objects and Mack::Rendering::Engine::* objects. Let me explain the difference.</p>
<h4>Mack::Rendering::Type::*</h4>
<p>A type is something like :action, :text, :inline, :url, etc&#8230; That is the type of thing you want to do. I want to render an action. I want to render a url, etc&#8230; There are classes for each of these types, and you can easily add your own. These types do all sorts of work before they pass it off to an engine, if need be. For example, in the case of Mack::Rendering::Type::Partial the render method does the work of inserting an &#8216;_&#8217; in the appropriate place, so the file can found.</p>
<pre>&lt;%= render(:partial, "users/form") %&gt; # =&gt; "users/_form"</pre>
<p>Once that happens it tries to find an engine to process the partial.</p>
<h4>Mack::Rendering::Engine::*</h4>
<p>An engine does the actual work of rendering the io, with the binding of the Mack::Rendering::ViewTemplate object, it&#8217;s been given by the results of the render method in the Mack::Rendering::Type::* object. Engine examples would be, Erubis (ERB), Markaby, Haml, and Builder::XmlMarkup, all of which are included with Mack in this release. New engines can easily be plugged in and registered with the system.</p>
<p>Coming soon a tutorial on adding PDF::Writer support using the new system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2008/05/20/the-new-rendering-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release 0.5.0</title>
		<link>http://www.metabates.com/2008/05/06/release-050/</link>
		<comments>http://www.metabates.com/2008/05/06/release-050/#comments</comments>
		<pubDate>Tue, 06 May 2008 18:33:47 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[darsono sutedja]]></category>
		<category><![CDATA[data mapper]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[erub]]></category>
		<category><![CDATA[genosaurus]]></category>
		<category><![CDATA[mack]]></category>
		<category><![CDATA[rcov]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.mackframework.com/?p=91</guid>
		<description><![CDATA[I know I&#8217;ve been talking about this release for a while now, and here it finally is. There&#8217;s some good bug fixes in here, a few new rake tasks, and some other little things like that. The biggest thing, however, is what&#8217;s been causing a stir online now for the past few days, I&#8217;ve split [...]]]></description>
			<content:encoded><![CDATA[<p>I know I&#8217;ve been talking about this release for a while now, and here it finally is. There&#8217;s some good bug fixes in here, a few new rake tasks, and some other little things like that.</p>
<p>The biggest thing, however, is what&#8217;s been causing a stir online now for the past few days, I&#8217;ve split out the ORM support into separate gems. I&#8217;m not going to go over it again, you can find all the details here:Â <a href="http://www.mackframework.com/2008/05/04/orms-and-mack/" target="_blank">http://www.mackframework.com/2008/05/04/orms-and-mack/</a></p>
<p>Needless to say this is a good release to get, if not for the bug fixes alone, but for the great db:create rake tasks that are now in there. Thanks, again, to Darsono Sutedja for his great contributions.</p>
<p>Changelog</p>
<ul>
<li>Added rake db:create and db:create:all rake tasks.</li>
<li>Refactored out constants, such as MACK_ROOT and MACK_ENV and made them into Mack::Configuration.env, Mack::Configuration.root, etc&#8230;</li>
<li>Added test:stats and test:coverage Rake tasks.</li>
<li>Removed support for ActiveRecord and DataMapper and moved them into their own gems.</li>
<li>Fixed a bug where yields in ERB weren&#8217;t giving the desired results.</li>
<li>DataMapper database.yml file can now be nested, and is generated as such.</li>
<li>Cleaned up some tests, and refactored the HTML generation stuff.</li>
<li>Fixed a bug with the scaffold generating &#8216;bad&#8217; methods instead of &#8216;post&#8217;</li>
<li>Made error_messages_for more compatible with DataMapper.</li>
<li>Fixed a bug loading url.rb and uploaded_file.rb found by Phil Darnowsky</li>
<li>[dsutedja] Render method (in controller_base) now accepts response status code.</li>
<li>gem: mack_ruby_core_extensions 0.1.23</li>
<li>gem: genosaurus 1.1.4</li>
<li>gem: datamapper 0.3.2</li>
<li>gem: rcov 0.8.1.2.0</li>
<li>gem: mack-data_mapper 0.5.0</li>
<li>gem: erubis 2.6.0</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2008/05/06/release-050/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release 0.4.6</title>
		<link>http://www.metabates.com/2008/04/18/release-046/</link>
		<comments>http://www.metabates.com/2008/04/18/release-046/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 21:55:04 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[erubis]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[mack]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[scaffold]]></category>
		<category><![CDATA[thin]]></category>

		<guid isPermaLink="false">http://www.mackframework.com/?p=80</guid>
		<description><![CDATA[This is a pretty cool release. First off Thin has been updated to 0.8.0, a rather nice, stable release. ERB has been replaced with ErubisÂ to give a significant improvement in speed, which, after all is one of Mack&#8217;s most important traits.Â  There&#8217;s been a general overhaul of the generators included with Mack. Mostly, cleaning them [...]]]></description>
			<content:encoded><![CDATA[<p>This is a pretty cool release. First off Thin has been updated to 0.8.0, a rather nice, stable release. ERB has been replaced with <a href="http://www.kuwata-lab.com/erubis/" target="_blank">Erubis</a>Â to give a significant improvement in speed, which, after all is one of Mack&#8217;s most important traits.Â </p>
<p>There&#8217;s been a general overhaul of the generators included with Mack. Mostly, cleaning them up. With that said things like the scaffold, model, and migration generators have been updated to do what a lot of people have been asking for, that is take a &#8216;cols&#8217; parameter and build out the generated code corrrectly. This really makes life, very, very simple.</p>
<p>There will be a re-written &#8216;blog&#8217; tutorial coming out soon to make use of this, as well as migration support that&#8217;s now part of Mack.</p>
<p>Very exciting stuff! Enjoy!</p>
<p>Changelog:</p>
<ul>
<li>Mack now uses Erubis, http://www.kuwata-lab.com/erubis/, for it&#8217;s rendering engine instead of ERB. This makes Mack even faster now! Yippie!</li>
<li>Added rake generate:model name=&lt;model_name&gt; (optional: cols=&lt;col_1&gt;:&lt;col_1_type&gt;,&lt;col_2&gt;:&lt;col_2_type&gt;) This will also create a migration for you.</li>
<li>Updated rake generate:migration name=&lt;model_name&gt; (optional: cols=&lt;col_1&gt;:&lt;col_1_type&gt;,&lt;col_2&gt;:&lt;col_2_type&gt;) This will create the proper table migration for you.</li>
<li>Updated rake generate:scaffold to use the ModelGenerator now.</li>
<li>ScaffoldGenerator now create input fields based on the type of columns, if any, passed in.</li>
<li>Overall general refactoring of the generator classes.</li>
<li>Fixed a bug with request logging not, well, logging.</li>
<li>gem: erubis 2.5.0</li>
<li>gem: thin 0.8.0</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2008/04/18/release-046/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release 0.3.0</title>
		<link>http://www.metabates.com/2008/03/19/release-030/</link>
		<comments>http://www.metabates.com/2008/03/19/release-030/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 20:43:51 +0000</pubDate>
		<dc:creator>Mark Bates</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mack]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[rijndael]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.mackframework.com/2008/03/19/release-030/</guid>
		<description><![CDATA[I&#8217;ve been holding back this release so I could get distributed routing into it, but it appears that there&#8217;s still a little more work that needs to be done before it&#8217;s ready to go. I&#8217;m hoping to get it out by the beginning of next week, but don&#8217;t quote me on that. Instead of focusing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been holding back this release so I could get distributed routing into it, but it appears that there&#8217;s still a little more work that needs to be done before it&#8217;s ready to go. I&#8217;m hoping to get it out by the beginning of next week, but don&#8217;t quote me on that.</p>
<p>Instead of focusing on what didn&#8217;t make it in, let&#8217;s talk about what did make it in! There&#8217;s some cool stuff in this release.</p>
<h3>Format Driven Content</h3>
<p>Mack now allows you to drive different content based on the format requested. For example:</p>
<p>/posts &#8211; will render app/views/posts/index.html.erb<br />
/posts.html  &#8211; will also render app/views/posts/index.html.erb<br />
/posts.xml  &#8211; will render app/views/posts/index.xml.erb &#8211; A special note *.xml.erb files, despite their name, do NOT get run through ERB, instead they use the XML Builder library<br />
/posts.js  &#8211; will render app/views/posts/index.js.erb<br />
etc&#8230;</p>
<p>Alternatively, in your action you can now define &#8216;want&#8217; blocks, to run specific code based on the format. Example:</p>
<pre>class PostsController
  def index
    # find all the posts in the system
     @posts = Post.find(:all)
    wants(:html) do
      # this will only be run if html is requested.
      # we need a username for a 'welcome message in the view'
      @username = @user.username
    end
    wants(:xml) do
      # this will only be run if html is requested.
      # find the last published date
      @last_pub_date = Rss.find_last_by_date_by_object(:posts)
    end
  end
end</pre>
<h3>XML Builder Support</h3>
<p>I&#8217;m not going to go into this, there is another nice post coming shortly that will explain how to use this library to add RSS to our blog demo. Here&#8217;s the <a href="http://www.mackframework.com/2008/03/19/adding-rssxml-feeds-to-our-blog-demo/">post</a>.</p>
<h3>Built-in Encryption</h3>
<p>In every app I&#8217;ve ever built I found the need to use encryption. Whether it&#8217;s for encrypting something into a cookie, a password in the database, or a file on disk, we all need encryption, so I&#8217;ve baked the crypt gem into Mack.</p>
<p>At the very simple level you can easily do this in your code:</p>
<pre>@my_encrypted_value = _encrypt("hello world")</pre>
<p>and you&#8217;ll be returned a nice pieced of garbled data using the Crypt/Rijndael library. Decrypting is just as easy:</p>
<pre>_decrypt(@my_encrypted_value) # =&gt; "hello world"</pre>
<p>See, I told you it couldn&#8217;t be easier. It gets even better you can even define your own &#8216;worker&#8217; to implement other encryption schemes. It&#8217;s as simple as this:</p>
<pre>class Mack::Utils::Crypt::HorribleWorker
  def encrypt(value)
    value.reverse
  end
  def decrypt(value)
    value.reverse
  end
end

_encrypt("hello", :horrible) # =&gt; "olleh"
_decrypt("decrypt", :horrible) # =&gt; "hello"</pre>
<p>See how easy that was? You can also do:</p>
<pre>@my_encrypted_value = "Hello".encrypt
@my_encrypted_value.decrypt #=&gt; "Hello"</pre>
<p>Either way it&#8217;s now easy to handle encryption in your funky cool Mack app.</p>
<p>Changelog:</p>
<ul>
<li>Ticket: #8 Xml Builder Support</li>
<li>Ticket: #7 Ability to drive certain content based on &#8216;format&#8217;</li>
<li>Ticket: #9 Added a global encryption system to make encrypting/decrypting of strings easy to use</li>
<li>gem: builder 2.1.2</li>
<li>gem: crypt 1.1.4</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.metabates.com/2008/03/19/release-030/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.664 seconds -->

