# Rhtml templates and syntax

**URL:** <https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403>\
**Category:** Rails\
**Created:** [March 20, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403 "2006-03-20T21:23:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kronidas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e79b87/32.png) [@kronidas](https://www.ruby-forum.com/u/kronidas)\
**Post date:** [March 20, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403/1 "2006-03-20T21:23:47Z")

</div>

Hello,  
where do we need \<% -%\> in templates ? What is the difference between  
\<%= %\> and it ?

---

<div class="post-metadata">

**Author:** ![kronidas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e79b87/32.png) [@kronidas](https://www.ruby-forum.com/u/kronidas)\
**Post date:** [March 20, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403/2 "2006-03-20T21:31:57Z")

</div>

\<%= %\> will execute the contained ruby and inject the result into the  
document.

\<% %\> will execute the contained ruby, but will NOT inject anything  
into the document (other than a blank line) … hence …

\<% -%\> will execute the contained ruby and will not inject anything  
into the document (not even a blank line).

-Derrick S.

---

<div class="post-metadata">

**Author:** ![kronidas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e79b87/32.png) [@kronidas](https://www.ruby-forum.com/u/kronidas)\
**Post date:** [March 20, 2006, 9:35pm UTC](https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403/3 "2006-03-20T21:35:34Z")

</div>

Derrick S. wrote:

> \<%= %\> will execute the contained ruby and inject the result into the  
> document.
> 
> \<% %\> will execute the contained ruby, but will NOT inject anything  
> into the document (other than a blank line) … hence …
> 
> \<% -%\> will execute the contained ruby and will not inject anything  
> into the document (not even a blank line).
> 
> -Derrick S.

Thank You, Derrick!  
🙂

---

<div class="post-metadata">

**Author:** ![kronidas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e79b87/32.png) [@kronidas](https://www.ruby-forum.com/u/kronidas)\
**Post date:** [March 20, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/rhtml-templates-and-syntax/55403/4 "2006-03-20T23:18:55Z")

</div>

You can also use - with the include. I.e.  
\<%= “blah” -%\>

This will inject “blah” into the output, but will not create a new line.

This is useful when you’re pulling data into something that is  
surrounded by quotes (like an HREF) where you don’t want the newlines  
and want to maintain readability.
