pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
MIT License
811 stars 47 forks source link

Can I keep pug template in separate file? #19

Closed mars-abd closed 6 years ago

mars-abd commented 7 years ago

Like this:

MyComponent/
    MyComponent.pug
    MyComponent.styl
    MyComponent.js

MyComponent.pug:

div(class=`${styles.container}`)
    p
        = this.state.text

MyComponent.js:


import React from 'react';
import styles from './MyComponent.styl';
import template from './MyComponent.pug'; // raw text loader

class MyComponent extends React.Component {
  render() {
    return pug`${template}`;
  }
}
ezhlobo commented 7 years ago

@mars-abd you can't (at least now).

It's also not planned for near future: https://github.com/pugjs/babel-plugin-transform-react-pug/issues/15

mars-abd commented 7 years ago

Sorry, it is duplicated issue

SilencerWeb commented 7 years ago

@mars-abd you can use this plugin https://github.com/bluewings/pug-as-jsx-loader/blob/master/README.md#import-pug-template

ezhlobo commented 6 years ago

Let's close this issue, since it's a duplicate. We can continue working on it, or just discuss it, within #15.

//CC @ForbesLindesay

ForbesLindesay commented 6 years ago

@ezhlobo you should have permission to close issues yourself if you want to. I agree that we should close this issue as a duplicate though :)

ezhlobo commented 6 years ago

@ForbesLindesay I actually don't have any permission here

ForbesLindesay commented 6 years ago

Ooops, it looks like I created a react-pug team, and added you to it, but forgot to add the repository. Should be fixed now :)