question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I keep pug template in separate file?

See original GitHub issue

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}`;
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ForbesLindesaycommented, Mar 21, 2018

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template Inheritance - Pug
Pug's template inheritance is a powerful feature that allows you to split complex page template structures into smaller, simpler files. However, if you...
Read more >
Rendering Pug Templates with Multiple Data Files
How to render your Pug templates from multiple data files using Gulp.
Read more >
compiling pug templates to single client side js file
This will compile all the templates in the path/to/templates folder to a templates.js file in /path/to/output. Include the generated file in ...
Read more >
Make multipage HTML development suck less with Pug
One of the most important features for pug is the partials. The idea is to have one file that holds most of your...
Read more >
Pug HTML Template Engine: A Beginner's Guide - SitePoint
The template engine will normally receive data from an external ... Syntax highlighting will make it much easier to work with Pug files, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found