@uyun/template-parser
根据页面配置生成源码
Last updated 5 years ago by chengdiao .
ISC · Repository ·
$ cnpm install @uyun/template-parser 
Private package

@uyun/template-parser

示例

import axios from 'axios'
import toDataURL, { createPage, renderTemplate, MemoryFs } from '@uyun/template-parser'
;(async function () {
  const { data } = await axios.get('template.zip', {
    responseType: 'arraybuffer'
  })

  // config为项目配置
  toDataURL(data, config).then(url => {
    // 生成的zip包的base64编码地址
    console.log(url)
  })

  // 为每一个页面生成代码
  // 该函数可用来实时预览当前编辑页面生成代码
  const pages = config.pages.map(page => ({
    name: page.name,
    code: createPage(page)
  }))

  // 下面代码相当于toDataURL
  MemoryFs.create(data)
    .then(memoryFs => renderTemplate(memoryFs, config))
    .then(memoryFs => {
      console.log(memoryFs)
      return memoryFs.toDataURL()
    })
    .then(url => {
      this.setState({ url })
    })

  MemoryFs.create(data).then(memoryFs => {
    memoryFs.readFile('./src/App.jsx').then(text => {
      console.log(text)
    })
  })
})()

Current Tags

  • 0.0.9                                ...           latest (5 years ago)

9 Versions

  • 0.0.1                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org