Block Types

Content Types

By default, OnlyHtml assumes that all template tags are text, and will generate text field inputs in the dashboard. You can easily change the type of dashboard input by specifying one of the types below.

{{oh intro type="html"}}

Additionally, template tags accept any number of parameters, which can tell OnlyHtml how to render the content, or how to further configure the dashboard input. Each content type below has a corresponding table which describes its parameters.

All types have these common parameters

Text

Just plain text :)

HTML

Image

link is an alias to a text field together with a URL field. It will render a an <a> tag

Icon

icon renders an <i> tag with automatic font-awesome css classes

Video

Video supports videos stored on Sanity.io using mux.com as a backend.

Date

Code Snippet

Raw code snippet to inserted into the page as is. In CMS will be presented in code aware editor.

Choice

Presents the user with a choice, from zero to multiple options. This would typically be used if you were asking for Yes/No answer, to choose one from many options, or in some case multiple-choice.

For example, this code will render "Love It" if the input field is selected and "Hate It" if it is u

{{oh my_opinion type="choice" options="Love It,Hate It"}} 

Another example where there is only one option. In case the input checkbox is not-selected no value will be rendered.

{{oh my_opinion type="choice" options="its-on"}} 

Reference

This feature is unstable

What if we have a a blog where each post has one author. We could set up a field of a post to be the author name and author picture, problem is it feels we are repeating ourselves. Instead we can use reference fields.

For example, lets look at this blog post

<main>
    {{#collection_item post}}
       <h1>{{oh title}}</h1>
       
       {{declare author type="reference" target="author"}}
       {{#with author}}
         <span>{{name}}</span>
       {{/with}}

    {{/collection_item}}
</main>

Last updated