pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to use webpack's rawloader to feed this plugin template files as strings?

andrewsuperlegit opened this issue · comments

I'm using threejs/react-three-fiber and this works:

const VideoElem = ()=>{
  const sphereArgs = {
    args: [500,60,40],
    scale: [-1,1,1],
    position: [0,0,0]
  }

  return pug`
mesh
    sphereGeometry(args=${sphereArgs.args} scale=${sphereArgs.scale} position=${sphereArgs.position}
        meshBasicMaterial
            videoTexture(attach="map" args=${video}
`
}

But these do not:

import videoelem from 'videoelem.pug?raw';

const VideoElem = (){
...
...
// pug keeps this as a string, but as the correct string-- like if this were passed to a pug compile function i'm pretty sure it'd do fine
return pug`${videoelem}`

// this just would print out videoelem because it's treating it as a string
return pug`videoelem`

// this fails because apparently the `` isn't a string even though it's a string?
return pug``.concat(videoelem)
}
...

I don't get it.
... I have a string that this plugin could totally compile if I could just figure out how to pass it to this pug`` ... function?

It seems so close. Is there a way to pass a string along to this pug transformer thing? Like

let string = 'div.derp'

pug`${{string}}`