I use 2 of these macro's on a page, giving me to forms each with a submit button.
This is the resul in html after pressing the second button. It gives me at least 4 linebreaks before rendering each macro (not sure if it's visible in the code view here).
Razor macro scripts producing whitespaces and linebreaks
Hi There,
I'm using a razor macro for some simple form stuff. In this macro I use inline @helper methods for rendering out parts of the html.
This works fine, however produces lots of whitespaces and linebreaks.
This is the .cshtml file for the macro:
I use 2 of these macro's on a page, giving me to forms each with a submit button.
This is the resul in html after pressing the second button. It gives me at least 4 linebreaks before rendering each macro (not sure if it's visible in the code view here).
Seems that rendering the .cshtml does not remove the linbreaks and whitespace before and after the @{ ... } code blocks.
Is this a Razor thing or is it the way Umbraco is hosting the Razor viewengine?
Anybody?
Thanks, Richard
Hmm, I haven't seen this before, it's not a huge problem is it? You could try restructuring a little:
I agree it is with those whitespaces. Seems that this bug is not fixed in the Razor engine (the MS one), http://forums.asp.net/p/1618460/4149182.aspx
I intended to write information like
John Doe, e-mail: [email protected], phone: 000-000 00 00
but needed to add a condition to omit the e-mail and phone address if there was none.
I first got this result
John Doe , e-mail: [email protected] , phone: 000-000 00 00
To get rid an extra whitespace before the comma's I came up with this ugly code:
<strong>@dn.name</strong>@if (dn.email!=""){@:, e-mail: <a href="mailto:@dn.email">@dn.email</a>
}@if (dn.phone!=""){@:, phone: @dn.phone
}
(Hm, I'm using IE9, and cannot get code formatting to work)
Regards
Jonas
is working on a reply...