Skip to content

Deprecation: layout tag

Taylor Hunt edited this page Aug 6, 2019 · 3 revisions

The <layout-*> tags are deprecated, replaced with first-class language support for custom tags and attribute tags.

<layout-use> → Layout components with <@tags> (or import)

Old:

<layout-use('../../layouts/site-layout.marko')>
  <layout-put into="body">
    Hello World
  </layout-put>
</layout-use>

New (Recommended):

<site-layout>
  <@body>
    Hello World
  </@body>
</site-layout>

However, you can also manually import a component, instead of using tag autodiscovery:

import SiteLayout from '../../layouts/site-layout.marko';

<${SiteLayout}>
  <@body>
    Hello World
  </@body>
</>

<layout-placeholder><${dynamic}>

Old:

<!doctype html>
<html>
<body>
  <layout-placeholder name="body">
    Default body content
  </layout-placeholder>
</body>
</html>

New:

<!doctype html>
<html>
<body>
  <if(input.body)>
    <${input.body}/>
  </if>
  <else>
    Default body content
  </else>
</body>
</html>

Without fallback content

Old:

<!doctype html>
<html>
<body>
  <layout-placeholder name="body"/>
</body>
</html>

New:

<!doctype html>
<html>
<body>
  <${input.body}/>
</body>
</html>