Undefined method MiddlemanCore Data - erb

I'm working on a static site using middleman and am trying to use mm's local data functionality.
Currently I have the required data directory within the source directory of my middleman project.
Inside the data directroy is a yaml file (home.yml)
Here's the structure of the file:
slides:
- image: "/img/slider/slide1.jpg"
image_alt: "Slide 1 alt text"
caption: "Slide 1 caption"
- image: "/img/slider/slide2.jpg"
image_alt: "Slide 2 alt text"
caption: "Slide 2 caption"
I'm then trying to loop through those slides in a html.erb file like so:
<%= data.home.slides.each do |s| %>
<figure class="slide">
<%= image_tag(s[:image], alt: s[:image_alt]) %>
<figcaption><%= s[:caption] %></figcaption>
</figure>
<% end %>
But middleman spits a NoMethodError on the compiled html file.
undefined method `home' for #<Middleman::CoreExtensions::Data::DataStore:0x4383918>
I don't know what I'm doing wrong. I tried moving the data directory up a level outside of the source folder but that did nothing.
It seems like middleman doesn't recognise the home.yml folder in side the data directory.
Any help with this is much appreciated as I've found there's not much in the way of documentation or support for middleman's data functionality.

You were pretty close -- you just had a minor typo. Note how I removed the equals "=" sign.
Change this line:
<%= data.home.slides.each do |s| %>
to this:
<% data.home.slides.each do |s| %>
The following markup should be generated once this is done:
<figure class="slide">
<img alt="Slide 1 alt text" src="/img/slider/slide1.jpg">
<figcaption>Slide 1 caption</figcaption>
</figure>
<figure class="slide">
<img alt="Slide 2 alt text" src="/img/slider/slide2.jpg">
<figcaption>Slide 2 caption</figcaption>
</figure>

Related

Kentico UniPager Pagination absolute url links

UniPager Pagination. Is it possible to put absolute links instead of relative ones in "PreviousGroupURL" and "NextGroupURL"?
My code:
<PreviousPageTemplate>
<a href="<%# URLHelper.GetAbsoluteUrl(Convert.ToString(Eval("PreviousURL", true))) %>" >Previous</a>
</PreviousPageTemplate>
<NextPageTemplate>
Next
</NextPageTemplate>
<PreviousGroupTemplate>
...
</PreviousGroupTemplate>
<NextGroupTemplate>
...
</NextGroupTemplate>
HTML source page:
Previous
1
<span>2</span>
3
<a href="http://local/en/test?strona=3" >Next</a>
</div>
In your transformation use something like:
<%# GetAbsoluteUrl(Eval<string>("NextGroupURL")) %>
From https://devnet.kentico.com/docs/11_0/api/html/Methods_T_CMS_Helpers_URLHelper.htm
Please refer below URLs - -
https://docs.xperience.io/k11/references/kentico-controls/generic-controls/paging-controls/unipager
https://devnet.kentico.com/questions/repeater-and-unipager-in-a-custom-control-(widget)
https://devnet.kentico.com/questions/kentico-unipager-not-working

Subline Text paste and indent windows 10

Using sublime text 3 cutting and then paste and indent using Ctrl+Shift+V it doesn't do what I think it should do:
<div>
<div></div>
</div>
function(){
test;
}
The expected result should be:
<div>
<div></div>
</div>
function(){
test;
}
Am I missing something?
This is not how Paste and Indent works. It is intended for situations when you copy a line or lines with one indentation and paste it into a block with a different indentation. For example:
<ul class="list1">
<li>One</li>
<li>
<ul class="innerList">
<li>OneA</li>
<li>OneB</li>
| <li>Three</li>
</ul>
</li>
<li>Two</li>
<li>Four</li>
</ul>
Now, I want to copy the line where the cursor is (containing <li>Three</li>) from innerList to list1. If I just do copy and paste (CtrlV), the indentation is wrong:
<ul class="list1">
<li>One</li>
<li>
<ul class="innerList">
<li>OneA</li>
<li>OneB</li>
<li>Three</li>
</ul>
</li>
<li>Two</li>
| <li>Three</li>
<li>Four</li>
</ul>
However, if I do "paste and indent" (CtrlShiftV):
<ul class="list1">
<li>One</li>
<li>
<ul class="innerList">
<li>OneA</li>
<li>OneB</li>
<li>Three</li>
</ul>
</li>
<li>Two</li>
| <li>Three</li>
<li>Four</li>
</ul>
The indentation is corrected for the current context. To do what you want to do, you'd need to use one of the many HTML and/or JS formatting plugins available on Package Control. I personally use HTML-CSS-JS Prettify, which runs on top of Node.js, but there are plenty to choose from.
as i remember there is Beautiful Html extension well be useful for your issue

How to click on Web check box using Excel VBA?

How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.

Kentico Trim in a transformation with Eval

I'm trying to trim ending white space from AlertTitle in an ascx transforamtion. I know there is TrimEnd, but i'm drawing a blank getting it to work.
The V9 Documentation has a method for this(https://docs.kentico.com/display/K9/Adding+custom+methods+to+transformations) but i don't want to fix the length.
Here's the transformatin code snippet.
<asp:placeholder id="alert" runat="server" Visible="false">
<li data-date="<%# Eval("AlertDate") %>">
<p class="alert-date"><%# FormatDateTime(Eval("AlertDate"), "MMMM dd, yyyy") %> </p>
<p class="alert-copy"><%# Eval("AlertTitle") %> <%# IfEmpty(Eval("AlertCopy"),"", "... <a href='" + GetDocumentUrl() + "'>" + CMS.Helpers.ResHelper.GetString("kff.Generic-ReadMore") + "</a> &raquo") %></p>
</li>
</asp:placeholder>
In addition to using Trim() or TrimEnd() in the transformation, you can also set it up so Kentico will automatically trim the fields when the form is submitted by checking the "Trim" checkbox under "advanced" Editing control settings.
Like so:
You probably need to cast the ouput of Eval to a string first:
<%# ((string)Eval("AlertTitle")).TrimEnd() %>
In v8 and newer, you can also use a different version of Felix's answer
<%# Eval<string>("AlertTitle").TrimEnd() %>

Kentico text/xml transformation conditional statmement

I have a transformation, used with a repeater, for a slider. All is working well. I have a slide caption, that isn't required. What I'm struggling with is a conditional statement where the caption tag doesn't show.
Here's my transformation:
<section class="imageSlide">
<figure role="group">
<img src="{% SlideImage %}" alt="{% SlideAlt %}">
<figcaption><p>{% SlideCaption %}</p></figcaption>
</figure>
</section>
What I'm hoping to do is not render the figcaption if there is no SlideCaption. SlideCaption isn't a required item. I had though if using jquery to change the display type of the <p></p> tags were empty, but want to avoid a lot of DOM manipulation.
I know that the syntax is something like this, but I haven't found a good example I can use as a base solution.
{% if(....) %}
Something like this should work. Didn't test it, so may need some tweaks.
{% IfEmpty(SlideCaption, "","<figcaption><p>" + SlideCaption + "</p></figcaption> ") %}
Another example for future reference if you dont want to be limited to using IfEmpty
{% if(SlideCaption != "" && SlideCaption != null) { return "<figcaption><p>" + SlideCaption + "</p></figcaption>" } %}

Resources