quantum-template/lib/index.js
function wrapper (fileContent, wrapperOptions) {
  const selection = quantum.select({
    type: '',
    params: [],
    content: fileContent.content
  })

  if (selection.has('template')) {
    const template = selection.select('template')

    // find out the name of the entity to replace with the page content
    const contentEntityType = template.has('contentEntityName') ?
      template.select('contentEntityName').ps() : 'content'

    // find the place to mount the rest of the page's content
    const contentEntity = template.select('content').select(contentEntityType, {recursive: true})

    const parentContent = contentEntity.parent().content()

    // find out where the mount point is
    const position = parentContent.indexOf(contentEntity.entity())

    // get the content to place at the mount point (ie remove all @templates from the page)
    const nonTemplateContent = selection.filter(x => x.type !== 'template')

    // make the replacement
    parentContent.splice.apply(parentContent, [position, 1].concat(nonTemplateContent.content()))

    return {
      content: template.select('content').content()
    }
  } else {
    return fileContent
  }
}
function wrapper (fileContent, wrapperOptions) {
  const selection = quantum.select({
    type: '',
    params: [],
    content: fileContent.content
  })

  if (selection.has('template')) {
    const template = selection.select('template')

    // find out the name of the entity to replace with the page content
    const contentEntityType = template.has('contentEntityName') ?
      template.select('contentEntityName').ps() : 'content'

    // find the place to mount the rest of the page's content
    const contentEntity = template.select('content').select(contentEntityType, {recursive: true})

    const parentContent = contentEntity.parent().content()

    // find out where the mount point is
    const position = parentContent.indexOf(contentEntity.entity())

    // get the content to place at the mount point (ie remove all @templates from the page)
    const nonTemplateContent = selection.filter(x => x.type !== 'template')

    // make the replacement
    parentContent.splice.apply(parentContent, [position, 1].concat(nonTemplateContent.content()))

    return {
      content: template.select('content').content()
    }
  } else {
    return fileContent
  }
}
function wrapper ( fileContent , wrapperOptions ) { const selection = quantum . select ( { type : '' , params : [ ] , content : fileContent . content } ) if ( selection . has ( 'template' ) ) { const template = selection . select ( 'template' ) // find out the name of the entity to replace with the page content const contentEntityType = template . has ( 'contentEntityName' ) ? template . select ( 'contentEntityName' ) . ps ( ) : 'content' // find the place to mount the rest of the page's content const contentEntity = template . select ( 'content' ) . select ( contentEntityType , { recursive : true } ) const parentContent = contentEntity . parent ( ) . content ( ) // find out where the mount point is const position = parentContent . indexOf ( contentEntity . entity ( ) ) // get the content to place at the mount point (ie remove all @templates from the page) const nonTemplateContent = selection . filter ( x => x . type !== 'template' ) // make the replacement parentContent . splice . apply ( parentContent , [ position , 1 ] . concat ( nonTemplateContent . content ( ) ) ) return { content : template . select ( 'content' ) . content ( ) } } else { return fileContent } }
Processes the page for wrapping templates.
Processes the page for wrapping templates .