Yii Framework Forum: Templated views - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Templated views Rate Topic: -----

#41 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 15 October 2008 - 08:58 PM

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
0

#42 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,856
  • Joined: 04-October 08
  • Location:DC, USA

Posted 15 October 2008 - 09:08 PM

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).
0

#43 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 16 October 2008 - 08:27 AM

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
0

#44 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,856
  • Joined: 04-October 08
  • Location:DC, USA

Posted 23 October 2008 - 01:50 PM

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.
0

#45 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,856
  • Joined: 04-October 08
  • Location:DC, USA

Posted 23 October 2008 - 01:53 PM

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 -->

0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users