Templated views

Originally I had clipped the directory folder at the "basePath" so the folder created in the runtime directory would be no deeper then the folder structure within the "protected folder", I thought doing it that way would be easier to track down the "compiled" version of the template, plus it would be faster to build this path (compared to the crc32 technique).

I thought about allowing assignment of attributes using simply {}, but then we encourage people to make it less XMLish and parsing the attributes could potentially become a real nightmare.

Do you think it is worthwhile to add a shortform for array assignments like

attribute="['name'=>12,'cssThing'=>'.white {color:white;}']"

would translate to

array('name'=>12,'cssThing'=>'.white {color:white;}')

(not really a big save…)

NZ

The problem with your approach is that the view path has to be limited to be under basePath. This is not always the case, however. Imagine you have several applications and some view files are shared. You would place those view files outside of the basePath of any application. The CRC way is also used by smarty, I believe (may not be exactly the same).

Regarding the quotes curly brackets, I think either approach has its cons and pros. Maybe support both? Anyway, you decide. I don't suggest using the simplified array syntax (I thought about it too).

Of course ! I had forgotten that the runtime folder could be specified as shared across projects. I will add an attribute to the extension to so that the developer can choose between the two methods, defaulting to the checksum method.

Regarding {} - I’ll run a few tests to see how good my regexp skills are ;)

Thanks for your help

z

Based on your code, I added CPradoViewRenderer to the framework. Check its supported syntax at: http://www.yiiframew…adoViewRenderer

Using a view renderer will degrade the performance by less than 5%. So it is quite usable. Thanks notzippy for the code and inspiration.

Below is the example of using this new syntax to rewrite the login page generated by yiic webapp:



<h1>Login</h1>





<div class="yiiForm">


<%= CHtml::form(); %>





<%= CHtml::errorSummary($user); %>





<div class="simple">


<%= CHtml::activeLabel($user,'username'); %>


<%= CHtml::activeTextField($user,'username') %>


</div>





<div class="simple">


<%= CHtml::activeLabel($user,'password'); %>


<%= CHtml::activePasswordField($user,'password') %>


<p class="hint">


Hint: You may login with <tt>demo/demo</tt>.


</p>


</div>





<% if(extension_loaded('gd')): %>


<div class="simple">


<%= CHtml::activeLabel($user,'verifyCode'); %>


	<div>


	<com:CCaptcha


		captchaAction="captcha"


		showRefreshButton={false} />


	<br/>


	<%= CHtml::activeTextField($user,'verifyCode'); %>


	</div>


	<p class="hint">Please enter the letters as they are shown in the image above.


	<br/>Letters are not case-sensitive.</p>


</div>


<% endif; %>





<div class="action">


<%= CHtml::activeCheckBox($user,'rememberMe'); %> Remember me next time<br/>


<%= CHtml::submitButton('Login'); %>


</div>





</form>


</div><!-- yiiForm -->