Git Product home page Git Product logo

placeholder-tag's Introduction

Placeholder-Tag

license npm Commit

🧩 html占位符标签. 指定位置替换文本, 支持树状关系.

Example

live demo

Quick Start

npm install placeholder-tag --save
const mock = `<!-- @placeholder:test:start -->testContent<!-- @placeholder:test:end -->`
PlaceholderTag.parse(mock).replace('testContentChanged')
// => `<!-- @placeholder:test:start -->testContentChanged<!-- @placeholder:test:end -->`

Methods

class PlaceholderTag {
  /**
   * 替换内容
   * @param {Array<number>} [indexs=[0]] indexs 索引组
   * @param {Array<string>|string} contents 内容组
   * @returns {String}
   */
  replace(indexs, contents) {}

  /**
   * 根据范围替换内容
   * @param {Array<number>} range range number
   * @param {String} content 要替换的内容
   */
  replaceRange(range, content) {}

  /**
   * 根据section查找最近的子元素
   * @param {String} section 子元素的section值
   * @returns {PlaceholderTag} 目标对象
   */
  find(section) {}

  /**
   * PlaceholderTag 实例快速查找
   */
  static map = {};

  /**
   * 创建 regExp
   * @returns {RegExp}
   */
  static createRegExp() {}

  /**
   * 拷贝 regExp
   * @param {RegExp} regExp
   * @returns {RegExp}
   */
  static cloneRegExp(regExp) {}

  /**
   * 根据 section 创建 RegExp
   * @param {String} section section name
   * @param {String} flags regExp flags
   * @param {Boolean} isNoCapture 是否不捕获
   * @returns {RegExp}
   */
  static createRegExpWithSection(section, flags, isNoCapture) {}

  /**
   * 清除 map 保存的数据
   */
  static clean() {}
}

placeholder-tag's People

Contributors

pinghuazhuang avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.