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

pass locals in #9

Closed
edrex opened this issue Jan 10, 2014 · 6 comments
Closed

pass locals in #9

edrex opened this issue Jan 10, 2014 · 6 comments

Comments

@edrex
Copy link

edrex commented Jan 10, 2014

For HTML compilation it is useful to pass local variables into a Jade template. How should this be handled in gulp-jade?

@edrex
Copy link
Author

edrex commented Jan 10, 2014

Nevermind. I looked at the tests and found that I can pass in locals using the data key. Still, a docs issue.

@edrex edrex closed this as completed Jan 10, 2014
@phated
Copy link
Member

phated commented Jan 21, 2014

Should I add locals as an alias to data?

@phated phated reopened this Jan 21, 2014
@diammondore
Copy link

can you share the example code how to use locals with data key?

@phated
Copy link
Member

phated commented Jan 22, 2014

@diammondore I have no idea what you are talking about.

@rayfranco
Copy link

@phated I think @diammondore means an example of how to pass data to the compiler using this plugin. Here is a simple example:

gulp.task('templates', function() {
  gulp.src('src/templates/**/*.jade')
    .pipe(jade({
      pretty: true,  // Feed the compiler
      data: {        // Feed the templates
        title: 'Hello World!'
      }
    }))
    .pipe(gulp.dest('build'));
});

@diammondore
Copy link

sorry, my previous comment is not enough to describe my issues

@rayfranco thanks, your code works, but as global data, I need little different

i use template inheritance

layout.jade is primary, which contains header and footer

// layout.jade
doctype html
html
head
  ...
  title= pageTitle
  ...
body
  include ../partials/_header
  block content
  include ../partials/_footer

i am trying to pass page title using variable pageTitle

index and inner pages using same template (layout.jade) except page title and page content in main area

// index.jade
extends layout
pageTitle = "Frontpage title"
block content
  h1 frontpage content
// inner.jade
extends layout
pageTitle = "Inner page title"
block content
  h1 Inner page content

the issue is that the variable pageTitle is empty when jade compile the index.html and inner.html

I'm not good at coding, so often use examples from documentation
will be grateful for any advise

@phated phated closed this as completed in 9366b59 Jan 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants