How can I include child directories in a bundle pattern? [duplicate] - asp.net-mvc

This question already has an answer here:
Include all files in a folder in a single bundle
(1 answer)
Closed 8 years ago.
In the code for my bundle configuration, assume the following is declared and initialised:
BundleCollection bundles;
I have js files that I want to include in the following directories:
~/Scripts/app
~/Scripts/app/some-namespace
I've been able to include the files in the app directory but not its child directories by using this:
bundles.Add(new ScriptBundle("~/bundles/app").Include("~/Scripts/app/*.js"));
I would like to include all of the js files from both directories in a single bundle in the most maintainable way possible.

I was able to achieve this by doing this:
var appScripts = new ScriptBundle("~/bundles/app")
.IncludeDirectory("~/Scripts/app", "*.js", searchSubdirectories: true);
bundles.Add(appScripts);

Related

how put directory in string , in dart? [duplicate]

This question already has an answer here:
How to set the current working directory in Dart?
(1 answer)
Closed 5 years ago.
I want to know what the current directory is. I don't want to shell out to run pwd. Is there an easy way to do this in Dart?
and also,
Is there a way, put name of directory into a string?
Re the current directory, from the documentation from the Directory class in dart:io (emphasis added).
In addition to being used as an instance to access the file system,
Directory has a number of static properties, such as systemTemp, which
gets the system's temporary directory, and the getter and setter
current, which you can use to access or change the current directory.
To get the name of a Directory as a string just use toString(), or perhaps the path property.

How to read files relatives to the .dart file? [duplicate]

This question already has answers here:
How to read file from an imported library
(2 answers)
Closed 6 years ago.
Suppose the following files:
lib/src/program.dart
lib/src/file.txt
I want to read file.txt contents from program.dart using a library that contains readingFunction(path):
//program.dart
String fileContents = library.readingFunction("./file.txt");
This throws an error, because the current path is the one in which execution was launched (or the package path if executing with pub run).
How could I achieve the reading with relative path instead of being forced to use "./lib/src/file.txt" path?
Use the Resource package.
It allows you to read files that are embedded in packages. Files are specified with a special URL that looks like package:package_name/path/to/file.txt (same as used in import statements).

ASP.NET MVC 4 bundle with wildcard in folder path

My team uses a custom NuGet package for installing jQuery UI, which puts the theme files into a directory structure like this:
Content
jquery-ui-1.10.3
images
jquery-ui.css
jquery-ui.min.css
I'm trying to use ASP.NET MVC 4 bundles to include this content in the BundleConfig class inside my application's App_Start folder like so:
bundles.Add( new StyleBundle( "~/bundles/css" )
.Include( "~/Content/normalize-{version}.css",
"~/Content/jquery-ui-{version}/jquery-ui.css",
"~/Content/Site.css" ) );
This throws an error when I run the site:
Directory does not exist.
Parameter name: directoryVirtualPath
I also tried:
bundles.Add( new StyleBundle( "~/bundles/css" )
.Include( "~/Content/normalize-{version}.css" )
.IncludeDirectory( "~/Content/jquery-ui-*", "*.css" )
.Include( "~/Content/Site.css" ) );
That doesn't work either (obviously). I can explicitly specify the version on the folder, but that defeats part of the benefit of using the bundle.
So how can I use a wildcard in the folder path?
You could use the overloaded version of IncludeDirectory which searches subdirectories.
Suppose you have the following file:
\Root\Content\jquery-ui-1.10.3\jquery-ui.css
Use this code to find and add it:
.IncludeDirectory("~/Content", "jquery-ui.css", true)
This is useful because it will always find jquery-ui.css, regardless of where you put it.
The downside to this method is that it will search for and include all jquery-ui.css files that it finds, which could cause some bugs if you don't ensure that only one jquery-ui.css exists.
(Remember that searching for subdirectories will also still search the root directory i.e. ~/Content)

Rails generating a new directory multiple levels deep [duplicate]

This question already has answers here:
How to create directories recursively in ruby?
(6 answers)
Closed 8 years ago.
i have built this little app that generates a excel document. i am trying to make a directory to stick it in. these documents are built differently depending on the #agency that people select. so i made this method to return the path since the path is used in a few places.
def reportsheet_dir
file_path = "#{Rails.root}/public/reportsheets/#{#agency.downcase.gsub("_","")}"
end
At the beginning of the method that creates the document i have this method that supposedly builds directories but it doest seem to be working
Dir.mkdir(reportsheet_dir) unless File.exists?(reportsheet_dir)
I keep getting. this
and i get
Errno::ENOENT at /addons/agency_report_builders
No such file or directory -/Users/fortknokx/Work/toolkit/public/reportsheets/empowerlogicbuilder
I think its because its multiple levels deep?? since public/reportsheets/agency_name/file_name has to be made. i could just go and make the folders but i would like to just make the dir each time because new agencies could be made at any time. is this possible?
Have a look at FileUtils.mkdir_p()
http://ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-mkdir_p
It will recursively create non-existent directories. Dir.mkdir will not.

How to include multiple php libraries in Symfony?

so, I have some php files in my apps/myprogram/lib folder. e.g. apps/myprogram/lib/myLibA.class.php
When I run in my modules/actions/ scripts, and try to use the functions in myLibA, I cannot. because symfony complains that the myLibA class is not defined.
do I need to specify anywhere in the symfony framework that myLibA.class.php is a required library?
Symfony's autoloader looks by default for your classes in the top-level <project>/lib directory. Any file in that directory or below (with the exception of "vendor") will be searched for classes. Symfony searches for any .php file with class declarations and adds them to the autoload system.
Additionally, you can add search paths in your application's autoload.yml file. For example, for one of my applications I've put a third-party Flickr library in <project>/vendor/phpFlickr, and my <project>/apps/frontend/config/autoload.yml file looks like:
autoload:
vendor_php_flickr:
path: %SF_LIB_DIR%/vendor/phpFlickr
recursive: on
That allows all classes below .../vendor/phpFlickr to be autoloaded.
this is an alternative way, you can define/add to your preExecute this:
public function preExecute()
{
$this->getContext()->getConfiguration()->loadHelpers('Foo', 'Bar');
}
taken from (http://oldforum.symfony-project.org/index.php/m/92916/)

Resources