定制 jg/kirby-wrappers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jg/kirby-wrappers

最新稳定版本:v2.0.1

Composer 安装命令:

composer require jg/kirby-wrappers

包简介

Kirby Wrapper Tags

README 文档

README

Simple wrapper tags for Kirbytext.

(wrapper)(/wrapper)<div class="wrapper"></div>

Installation

composer require jg/kirby-wrappers
Other installation methods

Download

Download and copy this repository to /site/plugins/kirby-wrappers.

Git submodule

git submodule add https://github.com/jg/kirby-wrappers.git site/plugins/kirby-wrappers

Example

Let's create a columns wrapper.

config.php

return [
  'jg.wrappers' => ['columns']
];

kirbytext

(columns)
  - One
  - Two
  - Three
(/columns)

output

<div class="columns">
  <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
  </ul>
</div>

Configuration

You can specify wrapper tags as Strings or Arrays with wrapper, class, tag, and attributes keys. Arrays are useful when you want the tag and the associated classname to be different, or you want to use a tag other than div.

config.php

return [
  'jg.wrappers' => [
    'center', // ← simplest
    [
      'wrapper' => 'gallery',
      'class' => 'image-gallery',
    ],
    [
      'wrapper' => 'card',
      'tag' => 'article',
    ],
    [
      'wrapper' => 'toggle',
      'attributes' => [
        'data-component' => 'toggle'
      ]
    ],
    [
      'wrapper' => 'modal',
      'class' => false // ← pass false to disable class
      'attributes' => [
        'data-component' => 'modal'
      ]
    ]
  ]
];

kirbytext

(center)(/center)
(gallery)(/gallery)
(card)(/card)
(toggle)(/toggle)
(modal)(/modal)

output

<div class="center"></div>
<div class="image-gallery"></div>
<article class="card"></article>
<div class="toggle" data-component="toggle"></div>
<div data-component="modal"></div>

Passing Data

You can optionally pass additional data into data-attributes:

kirbytext

(gallery size: large)(/gallery)

output

<div class="gallery" data-size="large"></div>

Nesting

Does nesting work? Yep.

kirbytext

(outer)(inner)(/inner)(/outer)

output

<div class="outer"><div class="inner"></div></div>

Why?

This is handy if you need to wrap content in Kirby to do fancy stuff with js and css.

Notes

  • Kirby 2 version found under the k2 branch

统计信息

  • 总下载量: 1.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-08