I have a page where I want to use the date as the title. I see that permalinks allow you to use that data, however, I cannot do the same to use the date in my title. Is there a way to do this in Eleventy?
---
title: "{{date}}"
date: 2020-10-10
---
This returns {{date}} in the title.
Eleventy currently supports using data variables and template syntax only for the permalink field, but not for any other frontmatter fields:
permalink: Change the output target of the current template. Normally,
you cannot use template syntax to reference other variables in your
data, but permalink is an exception. Read more about Permalinks.
Source. See also: Use data variables in Permalink.
However, you can use template strings and data variables if you use Computed Data. Something like this should work:
---
eleventyComputed:
title: "{{ date }}"
---
See Using a template string. Alternatively, you can do the same thing with JavaScript (if you need more control over the date format, for example). If you want to derive your title from date for all pages in a specific directory or of a specific layout template, you can also use directory data files or layout front matter.
Related
I am creating a template in Wikipedia to link articles to an external website which is a book archive called fadedpage.com. I am generating a url to link to a specific author page. Part of the url is the author's name which contains one or more spaces. For example, the url for the author "Ian Fleming" is: http://fadedpage.com/csearch.php?author=Fleming, Ian. My template call structure is {{FadedPage|id=Fleming, Ian|name=Ian Fleming|author=yes}}.
For my template I am replicating an existing template which uses a script coded in lua to parse the template arguments. I have been able to generate all of the url except for the space character between the last and first name.
I could code the template call as: {{FadedPage|id=Fleming,%20Ian|name=Ian Fleming|author=yes}} which works OK but I would rather have the call format as it looks on the fadedpage website, ie. with the embedded space. So I need a way in lua to find the space character within the string and substitute it for the string "%20". So far I haven't figured out how to do it. Any help would be appreciated.
I am trying to use a typeahead functionality within an inputtext-field.
Instead of populating the values by using a fixed list or a DBColumn (which is way to slow for more than thousands of entries), I would like to use the url parameter of the typeahead properties.
What I have done so far is that:
<xp:inputText value="#{docEntry.namUsers}" id="namUsers">
<xp:typeAhead mode="external" valueMarkup="false" minChars="3" var="namEntries" frequency="1" maxValues="10" id="typeAheadNamUsers">
<xp:this.url><![CDATA[#{javascript:"http://server/databse.nsf/view?ReadViewEntries&OutputFormat=JSON&StartKey=" + getComponent("namUsers").getAttributes().get("value");}]]></xp:this.url>
</xp:typeAhead>
</xp:inputText>
When entering the minimum required characters I can see that a GET-request is fired. And this GET-request returns the desired content of the view.
But I didn't find any way to fetch the returned information in order to parse the content and give a valid list to the typeahead element.
Has anyone tried using the url property of the typeahead element?
You cannot use the url parameter of the typeahead this way. The parameter is only a configuration parameter for the initialisation of the typeahead widget and will not get updated with your server side code.
If you look in the firebug console you can see that there is an URL parameter named $$value which is automatically added to the url you have defined (containing the characters for the lookup itself).
The response for the Typeahead needs to be simple HTML code:
<ul>
<li>Result 1</li>
<li>Result 2</li>
<li>Result 3</li>
<li>...</li>
</ul>
[It can be changed for display purposes, but it needs to be HTML]
There is no JSON / no XML for external requests.
You could create a $$ViewTemplate (HTML content) for your view to return the required format, and f.e. add a redirection agent:
Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Dim hlp
Set doc = session.Documentcontext
hlp = Split( doc.QUERY_STRING_DECODED(0), "$$value=" )
Print "[http://example.com/YourDB.nsf/View?OpenView&startKey=" & hlp(1) & "]"
End Sub
Then you can set the url to your Agent instead to the view:
<xp:typeAhead mode="external" valueMarkup="false" minChars="3"
frequency="1" maxValues="10" id="typeAheadNamUsers"
url="http://example.com/YourDB.nsf/RedirectAgent?OpenAgent">
</xp:typeAhead>
AFAIK the data expected from that URL needs to be "collection ready", meaning a list of values separated by a delimiter (comma or newline). ?ReadViewEntries doesn't deliver that format, so you want to use a HTML passthru view instead.
I would challenge you assumption. If your database for the lookup is on the same server, what makes you presume that adding HTTP latency will be faster than a #DbColumn? If it is a different server it would be an interesting test -- besides it would be better anyhow to keep the value lookup on the same server.
Another question: is the user experience with thousands of potential values in a typeahead list really what is efficient, effective and pleasant?
I am just starting a very basic program in Grails (never used it before, but it seems to be very useful).
What I have so far is:
in X.groovy,
a String named parameters, with constraint of maximum length 50000 and a couple other strings and dates, etc.
in XController.groovy,
static scaffold = X;
It displays the scaffold UI (very handy!), and I can add parameter strings and the other objects associated with it.
My problem is that the parameters string is a long string with formatting that is pasted in by the user. When it is displayed on the browser, however, it does not retain any carriage returns.
What is the best way to go about this? I'm a very beginner at Grails and still have lots and lots of learning to do on this account. Thanks.
The problem is that the string is being displayed using HTML which doesn't parse \n into a new line by default. You need to wrap the text in <pre> (see: http://www.w3schools.com/tags/tag_pre.asp) or replace the \n with <br/> tags to display it correctly to the user.
Hi I am using biztalk's FlatFile parser (using XML schema) to part a CSV file. The CSV File sometimes contains invalid date - 1/1/1900. Currently the schema validation for the flat file fails because of invalid date. Is there any setting that I can use to allow the date to be used?
I dont want to read the date as string. I might be forced to if there is no other way.
You could change it to a valid XML date time (e.g., 1900-01-00:00:00Z) using a custom pipeline component (see examples here). Or you can just treat it as a string in your schema and deal with converting it later in a map, in an orchestration, or in a downstream system.
Here is a a C# snippet that you could put into a scripting functoid inside a BizTalk map to convert the string to an xs:dateTime, though you'll need to do some more work if you want to handle the potential for bad input data:
public string ConvertStringDateToDateTime(string param1)
{
return DateTime.Parse(inputDate).ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
}
Also see this blog post if you're looking to do that in multiple places in a single map.
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.