How to say if something equals to a string in Sightly? - sightly

In Sightly, I want to have if statement as in below
if x == "Australia"
then
execute the html below
I am looking for some tutorial on how to do this or some example. This may not be worth asking here. However, please, may I have an example like that? I am stuck

I think you could do something like this:
<div data-sly-test="${x == 'Australia'}">
HTML about Australia
</div>
Here are some tutorials as well:
http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-1/

Related

Razor if statement inside HTML

Why I can do that:
#Code
Dim styleVisible As String = if(Model.IndicateurAchatPeriodique,"block","none")
End Code
<div id="#sectionDCAId" style="display:#styleVisible">...
but not that:
<div id="#sectionDCAId" style="display:#If(Model.IndicateurAchatPeriodique,"block","none")">
I just moved the if instruction inside the HTML but it throw an error. Why the compiler can't understand it?
I don't need solutions, just an explanation. Thanks
The compiler seems to have problems with inline VB.NET Ifs. Not sure if it is a bug or it just isn't quite that clever. I know you haven't asked for a solution, but if you put an extra set of brackets in to help it then it will probably work - as in #(If(Model.IndicateurAchatPeriodique,"block","none"))

How to Filter a list of objects in Thymeleaf on an object Property

I have tried searching on StackExchange and also looked at other places using Google and the Thymeleaf reference as well. It seems like the syntax below should work but it is not filtering the list based on condition given.
<th:block th:each="dayNumber :${#numbers.sequence(1,7)}">
<p th:if="${#lists.isEmpty(storeHours.?[#this.dayOfWeek eq #dayNumber])}" th:text="${dayNumber}"></p>
</th:block>
In above, we are trying to do a pretty simple filter. The storeHours is a list of Store Hours object. Each object has a property called dayOfWeek. It is an integer. In above, I am trying to simply print the missing day number. However, it is printing all 7 days.
I am sure I am missing something very basic here.
Any help is appreciated.
Try this code :
<th:block th:each="dayNumber :${#numbers.sequence(1,7)}">
<p th:if="${#lists.isEmpty(storeHours.?[dayOfWeek.equals(dayNumber)])}" th:text="${dayNumber}"></p>
</th:block>
Maybe you need to check your storeHours is NOT empty?
Then ${not #lists.isEmpty(...)}.

Rails 4 WYSIWYG Bootsy not displaying formatting

I've just followed the install instructions at the the bootsy gem page and it all looks good until I save and look at the post's content.
This is what the output looks like in the view:
<h2>Header</h2><h3>Sub head:</h3><br><img alt="Thumb 1320236280147" src="/uploads/bootsy/image/1/1320236280147.jpg">
It seems that none of the html formatting is being rendered as it is being escaped by quoation marks or something like that - has anyone else had this problem? I haven't seen any issues on the github page or on SO to point me in the right direction.
I haven't done anything yet apart from follow the gem install instructions but maybe I missed something or am just making a stupid mistake.
If there's anything else you want to know please just ask.
Cheers
You need to have something like this, escape html:
<%= f.bootsy_area(:body, class: 'bg-code').html_safe %>
Sergio is correct but have the .html_safe on the output rather than the input.
For example, on a post index:
<%= post.body.html_safe %>
Hope this helps.
maybe use raw?
<%= raw(post.body) %>
You can also add to bootsy.rb
config.editor_options = {
html: true
.....
}
to enable you to toggle html in the bootsy editor .

How to get the total items in an array(array length) in dust.js

I can't seem to figure out(I'm pretty sure that I'm over thinking or not thinking here) a way to get the length of an array in the following example. Can anyone please help me, or direct me to a good tutorial. https://github.com/linkedin/dustjs/wiki/Dust-Tutorial has mentioned the {#size} helper but does not have any examples.
<ul total-tems={#items.length/}>
{#items}
<li class="item-{$idx}">{.title}</li>
{/items}
</ul>
Thank you in advance.
Yep, I was clearly overlooking. I was not including ( require('dustjs-helpers'); ) in order to use
<ul total-tems="{#size key=items /}">
Hope this will help others out as well.
I don't know if is it a new feature of dustjs but now you can simply use {items.length} to access the array length with no need of helpers.

multiline grid extjs

i am newbie to Ext Js..i am working on ruby on rails...
can any1 suggest a good basic tutorial for "multiline grid" pllzz...
I guess for that you will have to return prepared data on the server and then add some css to it.
If you have one column then your data might look something like this:
<div> id and name </div>
<div> desc and pic </div>
Then add css for grid cells:
.x-grid3-cell-inner div { .... }
Would help if you posted an example.
Try this:
extjs-multi-line-grid-headers-and-cells
ext-js-grid-with-multiline-rows

Resources