I am trying to get this working, but am stuck with the razor.
I am trying the following for the moment but am receiving a macro error, what am I missing?
@inherits umbraco.MacroEngines.DynamicNodeContext
@using HtmlAgilityPack;
@using Umbraco.Community.ExtensionMethods.Strings; @{ var para = @Html.Raw(Model.bookText); var res = Strings.GetParagraph(@para, 7); <div> @Html.Raw(res) </div> }
But if I wrap the @para in quotation marks i get a blank <p> tag.
Razor Extract from RTE
Is there a way to extract paragraphs from an RTE to allow them to be split into seperate div's?
I have looked at using HtmlAgilityPack, but have got lost there.
Can someone make suggestions or let me know where to find out more about HtmlAgilityPack (with examples)
Many thanks.
TT
Hi, check out the GetParagraph method in the UmbracoExtensionMethods project https://github.com/warrenbuckley/UmbracoExtensionMethods/blob/master/ExtensionMethods/Strings.cs#LC233
Jeavon,
Thanks for this I will have a look at that.
TT
Great
Hi Jeavon,
I am trying to get this working, but am stuck with the razor.
I am trying the following for the moment but am receiving a macro error, what am I missing?
But if I wrap the @para in quotation marks i get a blank <p> tag.
Thanks
TT
Hi TT,
You don't need the
@Html.Raw(Model.bookText)
, justvar para = Model.bookText;
I think that's you only issue?
Jeavon
Hi Jeavon
Thank for that, but that still gives the macro error.
Regards
TT
Can you try
var res = Model.bookText.GetParagraph(7);
Also, how did you include the extension methods, compiled to dll or in app_code?
Hi Jeavon
I have and that still throws the error.
I used a complied DLL
Regards
TT
Ok, we need to know what this error is, this should help
Oh wait, I just noticed a problem with your brackets before, could you try:
Okay just tried that and got a macro error
Does not give an error, am about to try your error capture
Error I am seeing is:
'System.Web.HtmlString' does not contain a definition for 'GetParagraph'
With the code:
Ok, how about,
Sorry am still getting the error:
'string' does not contain a definition for 'GetParagraph'
May have it working, but am doing some more checking
Okay got this working, but it only seems to work with the try statement
Hurrah! How about like this:
Hi Jeavon
No it doesn't like that one - well it does but i just get a blank <p> tag and not the Text the other shows (which is what I want/expect).
Thanks for all of your help with this
Regards
TT
That's odd, I'll have a proper check tomorrow to see what's going on when I have something more useful than a iPad to hand :-)
Okay thanks.
Once again thanks for all your help
TT
Ok, so a bit of checking and the easiest solution is to make your variable explicit (the issue is due to DLR/CLR conversion), giving you:
That works!
Thanks very much Jeavon.
Regards
TT
is working on a reply...