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.

`filename: 'src/src'` works, but `filename: 'src/'` does not?

See original GitHub issue

Hi folks. Really happy with EJS.

This morning I found some things that seem weird around the <%- include %> feature.

Here are a couple of questions around the weirdness:

Why do I need filename on CLI, but not in express?

When I render a template with <%- include('') %> in an express server, I don’t get an error saying that I must use the filename option, but when I render the same template on the command line, I do. Does anyone know why that happens?

I think I found a bug – is a string like 'src/' filtered out anywhere in the code?

When compiling in the command line, if I specify src/ as the filename, it cannot find the files. If I specify src/src/ as the directory, it finds the files in the appropriate place. I don’t understand, because there’s only a src/, there is no src/src/.

I know this seems crazy. If you can’t reproduce or nothing comes to mind, I’ll try harder to reproduce under my conditions. Thanks for your time and effort!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
nchasecommented, Apr 28, 2016

awesome, thanks for the heads up. I created an issue in my repo (nchase/memetica#31) to remind me to fix this.

1reaction
RyanZimcommented, Apr 28, 2016

I don’t want you to have to spend too much effort on this – no need to be digging through my code

Well, I did anyhow! 😀

To fix your problem, you should delete Line 25, and edit Lines 53-72 to read:

ejs.renderFile(layoutPath, {
    data: {
      styles: data.styles
    },
    frameContent: content,
    index: contentPath.match('index.md') ? true : undefined,
    header: header,
    footer: footer,
    title: title,
    prefix: process.env.prefix || 'src/',
    requestStyle: '',
    bodyClass: data.bodyClass({
      frame: frame,
      singleColumn: matchers.singleColumn(content)
    }),
    hasCode: matchers.hasCode(content),
    notrack: false,
    published: true
  }, function(err, res){
    if (err) {
      // handle it
    } else {
      process.stdout.write(res);
    }
  });

Note that you’ll need to add error handling.


EJS does have JSDoc annotations. To view the API docs, clone the repo and run:

npm i
npm run doc

Open out/index.html in your browser, and there you are!

If I missed something, you can comment below and I’ll reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get the current file name in gulp.src() - Stack Overflow
js file I'm streaming all HTML files from the examples folder into the build folder. To create the gulp task is not difficult:...
Read more >
File differs from already included file only in casing: correct ...
ts' differs from already included file name 'src/models/headers/UserRole.ts' only in casing. I have tried multiple ways to fix it , but no luck ......
Read more >
Working With Files - Gradle User Manual
You may have a need to copy not just files, but the directory structure they reside in as well. ... For example, the...
Read more >
Autocomplete filenames in src attributes
I can't seem to get filename completion to work however. I'm prtessing Ctrl+Space to attempt to auto complete, but it's not working.
Read more >
Chapter 16. Working With Files
This is a simple way to 'implement' the FileCollection interface. Example 16.4. Implementing a file collection. build.gradle task list << { File srcDir...
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