chore: update doc template (#2142)

This commit is contained in:
0song 2021-06-03 20:37:31 +08:00 committed by GitHub
parent da622e10d1
commit 0cac0bda38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,7 +77,8 @@ const version = '1.0.0' // element version
const stripTemplateAndRemoveTemplate = code => {
const result = removeSetup(stripTemplate(code))
if (result.indexOf('<template>') === 0) {
return result.replace(/^<template>/, '').replace(/<\/template>$/,'')
const html = result.replace(/^<template>/, '').replace(/<\/template>$/,'')
return html.replace(/^[\r?\n|\r]/, '').replace(/[\r?\n|\r]$/, '').trim()
}
return result
}
@ -196,12 +197,15 @@ export default {
nextTick(() => {
const highlight = this.$el.querySelector('.highlight')
const hlcode = highlight.querySelector('pre code')
hlcode.innerHTML = sanitizeHTML(`<template>${this.codepen.html}</template>
<script>
const innerScript = `<script>
${this.displayDemoCode}
${'</sc' + 'ript>'}
`)
`
hlcode.innerHTML = sanitizeHTML(`<template>
${this.codepen.html}
</template>
${this.displayDemoCode ? innerScript : ''}`)
nextTick(() => {
if (this.$el.getElementsByClassName('description').length === 0) {