ckeditor and razor syntax templates -
i have interesting issue. have website sends emails. email templates straight forward 1 client wants me convert content public website email friendly html.
i want not solve problem specific website other unknown websites. remembered can run razor template engine.
long story short. working , working well. issue comes down this. when edits template razor style loops ckeditor acts quite strangely.
any idea how keep ckeditor screwing up?
<table style="width: 100%;" width="100%"> <tbody> @foreach (var row in body.indexpagerow) { foreach (var cell in row.teaser) { <tr> <td class="row">@raw(cell.teasercontent.a.html)</td> <td class="row">@raw(cell.teasercontent.div.innerhtml)</td> </tr> }} </tbody> </table> the above code when saved in ckeditor removes razor information , becomes empty table
<table style="width: 100%;" width="100%"> <tbody></tbody> </table>
the way can think of achieve use html comments in conjunction razor comments.
initially author razor template so:
@{ layout = null; } <!doctype html> <html> <head> <title>index</title> </head> <body> <table> <tbody> <tr><td>x</td><td>y</td></tr> @*<!--*@ @for (var x = 1; x < 5; x++) { (var y = 1; y < 5; y++) { @*-->*@ <tr> <td class="row">@html.raw(x)</td> <td class="row">@html.raw(y)</td> </tr> @*<!--*@ } } @*-->*@ </tbody> </table> </body> </html> the code above valid , render without error. when put html editor rearranged browser, need alter before displayed editing razor comments removed , html comments remain.
so, once have removed razor comments replacing instances of @*<!--*@ <!-- , instances of @*-->*@ --> should have following
<!doctype html> <html> <head> <title>index</title> </head> <body> <table> <tbody> <tr><td>x</td><td>y</td></tr> <!-- @for (var x = 1; x < 5; x++) { (var y = 1; y < 5; y++) { --> <tr> <td class="row">@html.raw(x)</td> <td class="row">@html.raw(y)</td> </tr> <!-- } } --> </tbody> </table> </body> </html> this render in html editor , wont mangled browser pointed out alfonso, example of on jsfiddle http://jsfiddle.net/wpgld/3/
once editing complete need capture html , reapply razor comments replacing instances of <!-- @*<!--*@ , instances of --> @*-->*@
intercepting html before , after enters ckeditor straight forward , documented. found following article explains little how ckeditor content on submit
how update ckeditor content on form submit – equivalent of onafterlinkedfieldupdate fckeditor
the following question covers this
Comments
Post a Comment