0.1.0 • Published 8 years ago

muleinthedust v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Mule in the Dust

npm.io Coverage Status

It's Lackey implementation for DustJS as Express renderer.

We used to use adaro. Anyhow we found it doesn't fully match our case. We decided to develop our own solution.

Helpers

@for

Allows iterating from n to m. Populate $idx field.

{@for from=0 to=10}
    {$idx}
{/for}

@has

Checks if path exists and is not empty.

{@has path="title"}
    {title}
{:else}
    Not title here
{/has}

@path

Creates new context from given path.

{@path path="items.{$idx}"}
    {title}
{/path}

@block

Embeds block, referred content, or decorates.

{@block path="items.0"/}
{@block path="items.0" template="_partials/item"/}
{@block route="/referred/page"/}
{@block route="/referred/page" template="_partials/as_facebook"/}

@list

Populates list of blocks.

{@list path="items"/}
{@list path="items" template="_partials/as_facebook"/}

@variant

Sets best matching variant as context.

{@variant path="items.1" locale="pl"}
    {title}
{/variant}

@editable

Extendable

Expose content for view / edit.

{@editable path="items.1.title" editMode=edit/}

@media

Extendable

Expose media for view / edit.

{@media path="items.1.image}" editMode=edit data-class="thumb"/}

@attr

Formatts content as html escaped string.

{@attr path="items.1.title" /}

@base

Wraps url with base.

{@base}any/url.html{/base}

POM 2.0

POMObject

_type: < 'Block' | 'List' | 'Variant' >
_props: < PropertiesMap >
_meta: < MetaMap >
<any> : < POMObject | String | Number >

Example

_type: Block
_meta:
    route: /blog/my-awesome-layout
    created: 1476784049
    updated: 1476784049
    createdBy: UserObject
    template: TemplateObject
_props:
    author: UserObject # one you can set manually
    theme: red
title: My awesome layout
blocks:
    type: List
    items:
        -
            type: Block
            _props:
                theme: blue
            copy: |
                My awesome layout is more awesome than you are
            example:
                type: Variant
                *: Example
                *:*:pl: Przykład

Restricted names:

  • any starting with underscore

PropertiesMap

<any> : < String | Number | Boolean | Variant >

MetaMap

<any> : < String | Number | Boolean >

POM universal meta

NameTypeDescriptionExample
routestringcanonical route to resource in the system/blog/my-awesome-layout
uristringfull uri as enteredhttps://example.com/de-DE/blog/my-awesome-layout
canonicalstringcanonical absolute urihttps://example.com/blog/my-awesome-layout
localestringlocale extracted from uri or sessionde-DE
basestirngrequired for ensuring links are aboslutehttps://example.com/de-DE/

Lackey specific meta

NameTypeDescriptionExampleValues
stateenumShows state of blockpublisheddraft, published
idnumberUnique id in the database134
creatednumberUnixtimestamp of record creation1476784049
updatednumberUnixtimestamp of record latest update1476784049
publishnumberUnixtimestamp of record embargo1476784049
authorUserObjectActual user who has created the record

Mapping POM to POM 2.0

POMPOM 2.0
data.route_meta.canonical
data.content.id_meta.id
data.content.$uriTBD
data.content.type_type
data.content.nametitle
data.content.route_meta.uri
data.content.createdAt_meta.created
data.content.publishAt_meta.publish
data.content.props.og_titletitle
data.content.props.og_url_meta.canonical
data.content.author_meta.author
data.content.author (editable)_props.author
data.content.template_meta.template
data.content.state_meta.state
data.content.layout$
data.content.populatedpopulated
data.content.taxonomies_taxonomies
template_meta.template.name
propertyproperty
stylesheets_meta.stylesheets
javascript_meta.javascripts
edit_edit
fragment_fragment
locale_meta.locale
host_meta.host
env_meta.env
defaultLocale_meta.defaultLocale
route_meta.route
session_session
postTBD
queryTBD

Title and OG:Title

In previous version of POM we had huge confusion around title and name of the page.

  • $.data.content.name
  • $.data.content.props.og_title
  • $.data.content.layout.title
  • any other

At the moment we will have just $.title which can (but don't have to) use variant og. Same goes for image and description. It should be edited via variant (i.e. how looks on facebook view).

Breaking changes

  • New data layout
  • Fields type dies, page is a block too
  • (Lackey feature) autopopulated fields from template should land in root of POMObject, not in $.data