niallobrien / hackathon-starter-plus

A boilerplate for Node.js web applications
MIT License
19 stars 4 forks source link

View Page Source shows raw code instead of rendered code #7

Closed slidenerd closed 5 years ago

slidenerd commented 5 years ago

Apologies if this is a silly question

screen shot 2019-02-03 at 5 32 51 pm

The relevant part of my pug file looks like this


extends ../layout

block content
  .pb-2.mt-2.mb-4.border-bottom
    h3 Sign in
  #login
    p {{message}}
    div
      b-btn(v-b-modal.modal1='') Launch demo modal
      // Modal Component
      b-modal#modal1(title='Bootstrap-Vue')
        p.my-4 Hello from modal!

My app.js file looks like this

new Vue({
  el: "#login",
  data() {
    return {
      message: "Hey from login man!"
    }
  }
})

The layout uses pug filters to add the final JS files after laravel mix is done with them screen shot 2019-02-03 at 5 35 27 pm

This would be my laravel mix file screen shot 2019-02-03 at 5 36 20 pm

Here's the custom pug filter


app.set('view engine', 'pug');
// Middleware for Jade/Pug custom filter for use with Laravel Mix
app.use((req, res, next) => {
  app.locals.filters = {
    'mix': (text, options) => {
      if (!text) return
      text = text.replace(/["']/g, '')

      const manifest = require(__dirname + '/public/mix-manifest.json')
      if (options.css) return `<link rel="stylesheet" href="${manifest[text]}">`
      if (options.js) return `<script type="text/javascript" src="${manifest[text]}"></script>`
      return text
    }
  }
  next()
})

I am assuming the pug filter is missing something or I may be wrong, would be great if you could share some insight

slidenerd commented 5 years ago

tested a simple page with bootstrap-vue on it and still shows the source, guess thats the default behavior