Sunday, 15 January 2012

razor - Use RazorEngine inside tinymce -



razor - Use RazorEngine inside tinymce -

i'm writing application uses given email template generate multiple messages.

the e-mail parser works fine. i'm using razorengine create e-mail template.

the problem need generate table using next build (a simple foreach):

<table> <tbody> <tr><th>pedido</th><th>nf</th><th>boleto</th><th>vencimento</th><th>valor</th></tr> @foreach (dynamic item in model.pagamentosematraso) { <tr> <td valign="top" width="76"> <p align="center"><span style="font-size: small;">@item.numeropedido</span></p> </td> <td valign="top" width="60"> <p align="center"><span style="font-size: small;">@item.numeronotafiscal</span></p> </td> <td valign="top" width="88"> <p align="center"><span style="font-size: small;">@item.numeroboleto</span></p> </td> <td valign="top" width="128"> <p align="center"><span style="font-size: small;">@item.datavencimento.tostring("dd/mm/yyyy")</span></p> </td> <td valign="top" width="119"> <p align="center"><span style="font-size: small;">@item.valorliquido.tostring("c2") </span></p> </td> </tr> } </tbody> </table>

when exit html editor, tinymce messes code, "fixing" code using this:

@foreach (dynamic item in model.pagamentosematraso) {} <table>

this issue happening on newer versions of tinymce - used take kind of markup.

is there viable solution allow tinymce take perchance broken html without trying prepare it?

my tinymce configuration is:

function initializetinymce() { $('textarea.tinymce').tinymce({ // location of tinymce script script_url: '/scripts/tinymce/tiny_mce.js', // general options theme: "advanced", plugins: " pa geb reak,legacyoutput,style,layer,table,save,advimage,advlink,emotions,iespell,inlinepopups,preview,media,searchreplace,print,c o nt extmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", width: "960", height: "500", entity_encoding: "raw", // theme options theme_advanced_buttons1: " bo ld, italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontse l ec t,fontsizeselect", theme_advanced_buttons2: " cu t,c opy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,image,cleanup,help,code,|,insert d @ e,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,||,fullscreen", theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", theme_advanced_statusbar_location: "bottom", theme_advanced_resizing: true, // illustration content css (should site css) //content_css: "/content/site.css", // drop lists link/image/media/template dialogs template_external_list_url: "lists/template_list.js", external_link_list_url: "lists/link_list.js", external_image_list_url: "lists/image_list.js", media_external_list_url: "lists/media_list.js", // replace values template plugin template_replace_values: { username: "some user", staffid: "991234" } }); }

since 3.4 not possible anymore turn off tinymce validator using config setting. html needs valid, may define gets accepted valid tinymce validator , not. have closer @ tinymce config params valid_elments , valid_children.

razor tinymce razorengine

No comments:

Post a Comment