Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jade blocks #292

Closed
leesus opened this issue May 22, 2014 · 5 comments
Closed

Jade blocks #292

leesus opened this issue May 22, 2014 · 5 comments

Comments

@leesus
Copy link

leesus commented May 22, 2014

I'm building a simple site with Harp, and I'm using yield to pull in page content. However, I'd like to use Jade blocks so that specific pages can output their own scripts into the layout.

At the moment, whatever I have in a block in my template just gets passed through as is into my layout.

For example:

// _layout.jade
html
  head
    title Hello, world
  body
    != yield
    div Random delimiter
    block scripts

// index.jade
h1 Hello, world
block scripts
  script(src='/some/script.js').
  div Not working

Outputs:

<html>
  <head>
    <title>Hello, world</title>
  </head>
  <body>
    <h1>Hello, world</h1>
    <script src="/some/script.js"></script>
    <div>Not working</div>
    <div>Random delimiter</div>
  </body>
</html>

As opposed to the intended result:

<html>
  <head>
    <title>Hello, world</title>
  </head>
  <body>
    <h1>Hello, world</h1>
    <div>Random delimiter</div>
    <script src="/some/script.js"></script>
    <div>Not working</div>
  </body>
</html>

Any ideas?

@kennethormandy
Copy link
Collaborator

Hey, unfortunately you basically have to choose between Jade’s blocks / extends system or Harp’s implicity _layout / partial system. There’s more details here to get you started: #220 Let me know how far that get’s you and I’m happy to help out more!

@jorgepedret
Copy link
Collaborator

I've used them together before and it's possible, it just takes a bit of time to understand Jade's blocks/extends and there might be some limitations/gotchas in terms of the paths.

Here's my answer in stackoverflow http://stackoverflow.com/questions/23815431/is-there-any-way-to-use-jade-blocks-in-harp-js

If you still want to use partials, you could do so in any jade file (even layout files), but I'd be careful with pushing it too far.

@leesus
Copy link
Author

leesus commented May 23, 2014

I got something working, using a custom layout that my main _layout inherits. Not the most elegant solution but it works!

Thanks

@leesus leesus closed this as completed May 23, 2014
@seb3point0
Copy link

Hi @leesus. Could you share your solution please?

@leesus
Copy link
Author

leesus commented Mar 4, 2016

@seb2point0 It's been a while since I did this, hopefully you get the gist, pardon the pun... https://gist.github.com/leesus/eaa55b986a4fddd8320e

@mrchief mrchief mentioned this issue Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants