Coder Social home page Coder Social logo

Comments (20)

haoxins avatar haoxins commented on May 29, 2024

base on path of gulpfile

from gulp-file-include.

wiz-Cll avatar wiz-Cll commented on May 29, 2024

it SHOULD base on the path of file who use @@include

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

add a option dir.

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

@wiz-Cll please try v0.3.0 and give a feedback.
If everything is ok, close this issue.>_<

from gulp-file-include.

r4fx avatar r4fx commented on May 29, 2024

Can you explain how to use it? I still have problem with partials

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

is this example helpful?

from gulp-file-include.

r4fx avatar r4fx commented on May 29, 2024

not exactly, I am looking for solutions for my case klei/gulp-inject#33

from gulp-file-include.

tsi avatar tsi commented on May 29, 2024

Me too.
I'm trying to do multi-level nested includes. e.g. include a file that includes other files.
If possible, referencing the path of file who use @@include will be helpful, or alternatively referencing the location of the gulp.js file would be fine.
Using @root was promising but didn't help since it was referencing my node_modules/gulp-file-include which lays outside of my project (is that normal?)
And giving an absolute path works fine for me but might break if I pass it to a developer with different path to the project.

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

gulp-file-include which lays outside of my project

haha, maybe is not normal, but I'll consider this.

And giving an absolute path works fine for me but might break if I pass it to a developer with different path to the project.

yes, absolute path is not good.

about @file, yes, seems some bugs, I'll fix it

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

actually, @file is relate to the file pass to gulp stream.

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

@tsi , I think @file all relate to the file pass to gulp stream is simple.

I'll fix the readme

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

@tsi
please see example

from gulp-file-include.

tsi avatar tsi commented on May 29, 2024

Yes, your example describes (but not solving) my problem very well:
All include paths are relative to index.html, even those called from the inner partials (e.g. a1.html).
Now, in my forked example I have a second page at a sub directory - /pages/somepage.html
I am able to call a1.html from page.html since I changed the path from a/a1/a1.html to ../a/a1/a1.html but the process will fail since a1.html includes a2.html using a path relative to index.html.
The best solution I can think of is allowing paths to be relative to gulp.js which is constant and can be referenced from anywhere safely.
Thanks!

from gulp-file-include.

tsi avatar tsi commented on May 29, 2024

@coderhaoxin did you see this? I realize this issue is closed, should I open a new one?

from gulp-file-include.

janpaepke avatar janpaepke commented on May 29, 2024

I think I know what the problem is.
The basepath is only set for the first file that is included.
So all further inclusions are relative to it, even if it in turn includes new files.

Imagine this structure:

|--file1.html
|--folder1
   |--file2.html
   |--folder2
      |--file3.html

Scenario: File1 includes File2 and File2 includes File3.

Now when I chose @file as the basepath what I expect would be this:
File1: @@include('folder1/file2.html')
File2: @@include('folder2/file3.html')

However this does not work because the plugin is looking for folder 2 in the same level as file1, because this was the first one to be included and thus set the basepath.
The only way it does work is like this:
File1: @@include('folder1/file2.html')
File2: @@include('folder1/folder2/file3.html')

Because files, especially when using relative paths, should be agnostic to which file includes them I think this is clearly a bug.

I will have a look at the source and see if I can figure out a quick fix.

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

@janpaepke yes, you're right.

But that will broken.

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

@janpaepke pr welcome. Just need a big version.

from gulp-file-include.

janpaepke avatar janpaepke commented on May 29, 2024

I made some changes and it works as expected for my usecase now.
It does fail one test though and I don't have more time to look into it.
But I guess it's a starting point...

from gulp-file-include.

janpaepke avatar janpaepke commented on May 29, 2024

glad I could help :)

from gulp-file-include.

haoxins avatar haoxins commented on May 29, 2024

πŸ‘ thanks

from gulp-file-include.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.