• Home
  • Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • ToSic.Razor.Blade
      • IHtmlTag
      • IHtmlTagsService
      • IScrub
      • Tag
      • Tags
      • Text
    • ToSic.Razor.Html5
      • A
      • Abbr
      • Address
      • Area
      • Article
      • Aside
      • Audio
      • B
      • Base
      • Bdi
      • Bdo
      • Blockquote
      • Br
      • Button
      • Canvas
      • Caption
      • Cite
      • Code
      • Col
      • Colgroup
      • Comment
      • Data
      • Datalist
      • Dd
      • Del
      • Details
      • Dfn
      • Dialog
      • Div
      • Dl
      • Dt
      • Em
      • Embed
      • Fieldset
      • Figcaption
      • Figure
      • Footer
      • Form
      • H1
      • H2
      • H3
      • H4
      • H5
      • H6
      • Head
      • Header
      • Hr
      • I
      • Icon
      • Iframe
      • Img
      • Input
      • Ins
      • Kbd
      • Label
      • Legend
      • Li
      • Link
      • Main
      • Map
      • Mark
      • Meta
      • MetaOg
      • Meter
      • Nav
      • Noscript
      • Object
      • Ol
      • Optgroup
      • Option
      • Output
      • P
      • Param
      • Picture
      • Pre
      • Progress
      • Q
      • Rp
      • Rt
      • Ruby
      • S
      • Samp
      • Script
      • ScriptJsonLd
      • Section
      • Select
      • Small
      • Source
      • Span
      • Strong
      • Style
      • Sub
      • Summary
      • Sup
      • Svg
      • Table
      • Tbody
      • Td
      • Template
      • Textarea
      • Tfoot
      • Th
      • Thead
      • Time
      • Tr
      • Track
      • U
      • Ul
      • Var
      • Video
      • Wbr
    • ToSic.Razor.Markup
      • Attribute
      • AttributeOptions
      • Attributes
      • ITag
      • Tag<T>
      • TagBase
      • TagChildren
      • TagCustom
      • TagList
      • TagOptions
      • TagText
    • ToSic.Razor.StartUp
      • StartUp

    Namespace ToSic.Razor.Blade

    This is the main namespace you will be working with. Add it to your page like this:

    @using ToSic.Razor.Blade;
    

    After that you can simply use the commands - so here's a super simple cshtml file:

    @using ToSic.Razor.Blade;
    <div>
        @Text.Ellipsis("this text is much too long &amp; will need to be truncated", 25)
    </div>
    

    Classes

    Tag

    Helper to quickly generate all HTML5 tags with a Tag.Img() or Tag.Table() syntax. This is the easiest and safest way to use in in Razor templates because you won't have naming issues etc.
    The objects are smart - for example this will automatically uri-encode 😎

    Tag.Img().Src("ünsafe.jpg")

    Important: Tag can easily be confused with the Tags object.
    new in 3.0

    Tags

    The Tags-API is for manipulating strings which contain html or should contain html

    • like stripping away tags, converting &lt;br> tags to new-lines and similar.
      Important: Tags can easily be confused with the Tag object.

    Text

    Many simple commands to work with Text / Strings

    Interfaces

    IHtmlTag

    Public interface for all Html5Tags

    IHtmlTagsService

    The service to generate HTML Tags.

    Tip

    This is the new, recommended way of generating tags, as it's better and functional

    Warning

    This looks almost the same as the static ToSic.Razor.Blade.Tag but there is a crucial difference The APIs return functional IHtmlTag objects. This is safer and more future proof, but you may run into surprises.

    Example:

    // Old Tag API - these two objects will be the same
    var tagOld = ToSic.Razor.Blade.Tag.Div();
    var tagOldWithId = tagOld.Id(...).Style(...).Class(...);
    // now tagOld and tagOldWithId are both the same objects with all changes applied
    
    // New API - assumes tagSvc is IHtmlTagsService
    // these two objects will NOT be the same
    var tag = tagSvc.Div();
    var tagWithId = tag.Id(...).Style(...).Class(...);
    // now tag is still an empty div-tag
    // while tagWithId is the tag wth everything set on 
    

    IScrub

    IScrub helps wash/clean html from things you want removed. It can take care of all tags, just specific tags or certain attributes.

    Note that it is implemented as an interface, so you must use Dependency Injection to get it.

    • Improve this Doc
    In This Article
    Back to top Generated by DocFX