Is there a way to get a list of sections defined in a layout file? For example, if I want to know what sections are defined in my Shared/_Layout.cshtml file is there a way to parse that Layout file so that I know what sections exist in the layout?
There's no built-in function I'm aware of because the name isn't necessarily known without executing the view.
You can probably just run a regular expression over your layouts, like
[^#]#RenderSection\(\s*"(?<name>[^"]+)"\s*\)
which accepts #RenderSection("foo") or #RenderSection( "foo" ), but skips ##RenderSection (the ## escaped #).
However, this assumes that the name of the section is passed in as a string literal. The view could also look like (not your typical situation, but possible):
#RenderSection(Model.SectionName)
In that case you're pretty much lost.
Related
I'm updating some older code that uses System.IO.Packaging to programmatically create Excel files. It ultimately calls CreatePackage on various bits of internal state to build out the documents. CreatePackage takes a ContentType parameter, and the existing code contains a list of constants like:
Const cxl07WorksheetContentType = "application/vnd...."
I'm trying to add support for PivotTables, which require a PivotCache. I cannot find the appropriate ContentType. I thought I might be able to discern it from within the file, looking in _Rels for instance, but these are always in URI form and bear no obvious relationship to these constants.
So...
is this even required? I passed Nothing and "" but that did not work.
does anyone know where these might be defined? I looked on the mime database, and the MS website, but nothing came up on either for "pivot"
where are these even used? they do not appear in the resulting Package as far as I can see.
I'm trying to get information from a XML file with Nokogiri. I can retrieve file using
f = File.open("/my/path/file.xml")
cac=Nokogiri::XML(f)
And what a get is a fancy noko:file. My row tags are defined like
<z:row ...info..../>
like
<Nokogiri::XML::Element:0x217e7b8 name="z:row" attributes=[#<Nokogiri::XML::Attr:0x217e754 name="ID_Poblacio" value="3">
and I cannot retrieve the rows using either:
s=cac.at_xpath("/*/z:row") or
s=cac.at_xpath("//z:row") or
s=cac.at_xpath("//row") or
s=cac.at_xpath("z:row")...
Probably I'm really fool but I cannot figure out which can be the issue.
Does anyone face this problem?
Thanks in advance.
P:S I tried to paste my cac file directly from bash but something wierd happens with format so I remove it from question. If anyone can explain how to do it I will appreciate it.
Your XML element name contains a colon, but it is not in a namespace (otherwise the prefix and uri would show up in the dump of the node). Using element names with colons without using namespaces is valid, but can cause problems (like this case) so generally should be avoided. Your best solution, if possible, would be to either rename the elements in your xml to avoid the : character, or to properly use namespaces in your documents.
If you can’t do that, then you’ll need to be able to select such element names using XPath. A colon in the element name part of an XPath node test is always taken to indicate a namespace. This means you can’t directly specify a name with a colon that isn’t in a namespace. A way around this is to select all nodes and use an XPath function in a predicate to refine the selection to only those nodes you’re after. You can use a colon in an argument to name() and it won’t be interpreted as a namespace separator:
s=cac.at_xpath("//*[name()='z:row']")
I have extended the pages table with one text field named TypoScript.
My intention was to use this field in TMENUs so that I can display arbitrary content as — for example — a dropdown for that page.
I know how to parse and output TypoScript in an extension, but I'm not sure if there's a way to do that in TypoScript alone.
So, in summary: Is it possible to have a TypoScript string and parse and output it in TypoScript?
You have to use a user function for that.
To be more specific, you have to use either the USER or the USER_INT content object.
I want to display raw data of one value from database. Table is quite big, with a lot of data and i need only 5 columns on index page. So i defined needed columns in criteria and used doSelectStmt with pager to paginate result.
Im displaying it like this:
http://pastebin.com/bccSkjs1
TEXT field contains some HTML and i want to display it normally (not escaped). However, 3 other fields (not show in code above) have to be escaped, because they can have some html too, but it cannot by interpreted as html.
I know that in normal object, i can do: $sf_data->getRaw("foo")->getBar() instead of $foo->getBar() to get expected result.
But how i can get same, when i dont have normal object, only array of data like in this case?
I know i can do $sf_data->getRaw("pager")->getResults() in a foreach, but it will unescape ALL fields which is tottal wrong!
Do you have to access the properties via arrays (which is ugly btw)?
If you were accessing the properties via the object getter methods, you could do:
echo $News->getText(ESC_RAW);
And your text field would be escaped.
I'm using Fitnesse SliM and I want to check if the result of a fixture is the empty string. Leaving the result field in Fitnesse empty just results in an ignored test which is obviously not what I want. I could solve this by extending the fixture code, but I wonder if this can be handled within Fitnesse itself.
It seems that Slim implies an empty string as an ignore, at least for the QueryTable fixture: A cell that is left blank in the table will be filled in from the result and counted as ignored.
Even though this is not considered a good solution, if you really have to you could use a regular expression to test on an empty string by matching on
=~/^$/
Another option is using the null fixture driver, as seen in http://fitnesse.org/FitNesse.SuiteAcceptanceTests.SuiteSlimTests.SlimSymbolsCanBeBlankOrNull
passing the word 'blank' simulates a empty string.
like:
|Check|That the returned string is | blank |
In this case - when you need to check with SLIM usage, whether the result is an empty string, you can use markup variable. Just define it somewhere on your page with test, like:
!define blank {}
And then call it anywhere you want:
|check|SomeFixtureName|${blank}|