I have a SharePoint Online list that has a column of type "Hyperlink" named URL. The Hyperlink column in the SharePoint list had two fields by default, "Enter a URL" and "Alternative text".
I am trying to use this list to display links, and specifically the "Enter a URL" field as my href. I am getting both the "Enter a URL" and "Alternative text" fields separated by a comma as my HREF value.
For example, a link to Google with an alt text of "link to google" returns this, concatenating both the "Enter a URL" and "Alternative text" fields:
https://www.google.com%2C%20link%20to%20google/
How do I wite the code below to only use the "Enter a URL" field (https://www.google.com) in my href?
<h2>Forms & Tools</h2>
<ul>
{{#each items}}
<li><a href="{{URL.textValue}}">{{Category.textValue}} - {{Title.textValue}}</a>
</li>
{{/each}}
</ul>
Adding a helper I am trying, I cannot get the helper to work. I am new to Handlebars Helpers. Can anyone give me a push in the right direction on how to get this helper setup?
<script>
Handlebars.registerHelper('splitSPUrl', this._splitSPUrl);
private _splitSPUrl = (urlFieldValue, propertyRequested) => {
if (urlFieldValue == null)
return null;
let spurl: ISPUrl = {
url: urlFieldValue.split(',')[0],
description: urlFieldValue.split(',')[1]
};
return spurl[propertyRequested];
}
</script>
{{splitSPUrl urlProp 'url'}}