@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
<!-- unimportant stuff, hidden -->
RazorBlade Text.Has(...) v1.1 These... <!-- unimportant stuff, hidden -->
@functions {
// Quick helper to convert true/false into emojis
string Boolmoji(bool value) { return value ? "✔️" : "❌"; }
// Create a row (TR) containing data about a Text.Has example
dynamic RowEmojified(string label, string value) {
var valueForShowing = value == null
? "null"
: "\"" + value.Replace("\n", "\\n").Replace("\t", "\\t") + "\"";
return Tag.Tr(
Tag.Td(label),
Tag.Td("Text.Has(" + Tags.Encode(valueForShowing) + ")"),
Tag.Td(Boolmoji(Text.Has(value))),
Tag.Td(Boolmoji(Text.Has(value, false)))
);
}
}
<h2>Examples</h2>
<table class="demo table table-hover">
<tr>
<th>Test</th>
<th>Code</th>
<th>Result</th>
<th>...when html counts</th>
</tr>
@RowEmojified("Null value", null)
@RowEmojified("Just spaces", " ")
@RowEmojified("text with only line breaks", "\n\n")
@RowEmojified("tabs, spaces and line breaks", "\n\t \n")
@RowEmojified("only nbsp characters", " ")
@RowEmojified("char-code of nbsp characters", " ")
@RowEmojified("real text", "real text")
@RowEmojified("Real text with nbps etc.", "real\n text ")
</table>
<h2>Special case: <BR> Whitespace</h2>
<ul>
<li>If your string is like Text.Has("<br>") it will be: @Text.Has("<br>")</li>
<li>If you want to ignore BRs, combine it with @hlp.TutLink("Tags.Br2Nl(...)", "blade220") </li>
<li>...resulting in:</li>
@Text.Has(Tags.Br2Nl("<br>"))
</ul>
<!-- unimportant stuff, hidden -->