I'm a newbie in web.py.
In my template script exists two FOR loops,it seems that the former(code1) interferes the later one(code2).Each one of them displays well alone,but abnormal when they are in one template script.
code1
$for data in posts:
<div id="title">
<h2>$data.title</h2>
</div>
<div id="marker">
<p>
User
$data.post_on $data.catalog
</p>
</div>
<div id="content">
<p>$data.content</p>
</div>
code2
$for (cat,ctr) in catcollector(posts).items():
<ul>
<li>$cat ($ctr)</li>
</ul>
I'm confused with this phenomenon.Does any one have idea about this? Thanks in advance~
I'm not sure this is your only problem, but it looks like your indentations are not correct. Things within the for loop should be indented.
Related
Laravel PHP fans, Any idea why this renders both the actual partial view and the No Data Found as well? And interestingly, it renders No Data Found first. If I do a dump and die in the if condition, I get that dd. If I put it in the else condition, I get it there. It must be that the page starts rendering before the data for regionLevel actually comes back. Then when it does it dutifully prints it out. Is there any way around this weirdness?
#if(isset($regionLevel) && count($regionLevel) > 0)
<div class="size-wrapper">
#include('manager/reports/order-data/sections/partials/region-partial')
</div>
#else
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-left m-t-5 m-b-5 m-l-10">No data found.</div>
</div>
</div>
#endif
i have a problem with one of my extensions i created with Extensionbuilder.
After i deleted the Cache there is no content anymore!
<f:flashMessages renderMode="div"/>
<div class="tx-camping-list">
<f:for each="{offers}" as="offer" iteration="it">
<div class="content-list-item">
<div class="contentLeft floatLeft">
<f:render partial="BaseItem/ListImages" arguments="{item:offer}" />
<div class="wrap-right floatRight">
<h3>
<f:link.action arguments="{offer:offer}">
<f:format.raw>{offer.names}</f:format.raw>
</f:link.action>
</h3>
<h4>
<f:format.raw>{offer.teaser}</f:format.raw>
</h4>
<div class="description"><f:format.crop maxCharacters="240"><f:format.html>{offer.description}</f:format.html></f:format.crop>
<p>
<f:link.action arguments="{offer:offer}">
<f:translate key="read_more" default="Read more" /> >
</f:link.action>
</p>
</div>
</div>
</div>
<div class="roomPrice floatRight">
<f:render partial="Price/ListPriceBox" arguments="{item:offer}" />
<f:render partial="BaseItem/Button" arguments="{item:offer,type:'Offer'}"/>
</div>
<div class="clearFloat"></div>
</div>
</f:for>
</div>
The image, {offer.names}, {offer.teaser} etc. is NULL, BUT the link {offer:offer} is working
When i reload the page the first time after i deleted the Cache i get the error:
The argument “each” was registered with type “array”, but is of type “string” in view helper
After a reload everything works fine except this plugin!
Maybe some of you can help me
Thanks
Use <f:debug> to find out what you real values are. You cannot loop over a string. Most likely, you are mistaken over your nesting level of your object.
Also do not use <f:format.raw> unless you already ensured, that the contend is htmlspecialchar'd. Otherwise you loose the XSS protection.
This can just fix the error if its caused by a missing reference on records
You could try to add the following line of code to your setup.ts (or .txt; depending on configuration and personal preferences):
File: slider/Configuration/TypoScript/setup.ts:
plugin.tx_slider.persistence.storagePid = 15
Note: replace tx_slider with your extensionkey and the 15 with the pagenumber where your records (in this case your offer-records) are located
I am beginning with AsciiDoctor and I want to output HTML. I've been trying to figure out how to create custom class in divisions, I searched google, manuals etc. and couldn't find a solution. What I want to do is simply write something like this:
Type the word [userinput]#asciidoc# into the search bar.
Which generates HTML
<span class="userinput">asciidoc</span>
but I want to have div tags instead of span. Is there any way to do it or should I just use something like
+++<div class="userinput">asciidoc</span>+++ ?
I think what you need is called "role" in Asciidoctor.
This example:
This is some text.
[.userinput]
Type the word asciidoc into the search bar.
This is some text.
Produces:
<div class="paragraph">
<p>This is some text.</p>
</div>
<div class="paragraph userinput">
<p>Type the word asciidoc into the search bar.</p>
</div>
<div class="paragraph">
<p>This is some text.</p>
</div>
You have now a css selector div.userinput for the concerned div.
See 13.5. Setting attributes on an element in the Asciidoctor User Manual (you can also search for "role").
You may want to use an open block for that purpose:
Type the following commands:
[.userinput]
--
command1
command1
--
Producing:
<div class="paragraph">
<p>Type the following commands:</p>
</div>
<div class="openblock userinput">
<div class="content">
<div class="paragraph">
<p>command1</p>
</div>
<div class="paragraph">
<p>command1</p>
</div>
</div>
</div>
The advantage is it can wrap any other block and is not limited to only one paragraph like the other answer.
For slightly different use cases, you may also consider defining a custom style.
I have this view which can rotate a div element. Something like
<div class="rotatable">
<div class="front">
{{outlet front}}
</div>
<div class="back">
{{outlet back}}
<div>
</div>
Now I have this index template which contains two of these rotatable elements. Each rotatable elements has a different front and back. So it could look like this
<div id="index">
{{#rotatable}}
{{outlet front App.FrontView1}}
{{outlet back App.BackView1}}
{{/rotatable}}
{{#rotatable}}
<div>This should show up inside {{outlet front}}</div>
{{outlet back App.BackView2}}
{{/rotatable}}
</div>
This doesn't work of course, but how should this be done ?
Cheers
I guess this question was a little bit unclear. Anyway, the answer is given in this post
EmberJs: how to use connectOutlet
I am using Scrapy and have run into a few places where it would be nice to use variables, but I can't figure out how. Meaning if I have some long string it would be nice to store it in a variable long_string and then select for it: hxs.select('\\div[#id=long_string]').
I'm sure this is supported by Scrapy and I just can't figure it out as it wouldn't make sense for you to always have to hard-code the string in.
Update:
So for the sample text below I want to extract the div where id="footer":
<div id="footer">
<div id="footer-menu">
<div class="region-footer-menu">
<div id="block-menu-menu-footer-menu" class="block-menu">
<div class="content">
<ul class="menu">
<li class="first leaf">FAQs</li>
<li class="leaf">Media</li>
<li class="leaf">Partners</li>
<li class="last leaf active-trail">Jobs</li>
</ul>
</div>
</div>
<div id="block-block-52" class="block block-block">
<div class="content">
<p>SUPPORT</p>
</div>
</div>
</div>
</div>
</div>
We initialize hxs = HtmlXPathSelector(response) for all the below segments.
The following code selects only the first div:
hxs.select('//div[#id=concat("foot","er")]')
This code selects nothing but gives no error:
hxs.select('//div[#id="foot"+"er"]')
Both of the below code segments select nothing and give no errors:
long_string = "foot"
hxs.select('//div[#id=concat(long_string,"er")]')
hxs.select('//div[#id=long_string]')
I would like to be able to do either of the bottom two methods and return the desired results.
Assuming + works for string concatenation in Scrapy, this should work:
hxs.select('//div[#id="' + long_string + '"]')
I'm not familiar with Scrapy, but I don't think you'll be able to select a div that doesn't exist.
have you tried?
hxs.select('\\div[#id="' + long_string_variable + '"]')