how do we include style sheets from a template file in smarty?
ca we use a relative path or does it have to be n absolute path?
structure might look like
project
|-- library
|-- css
|-- style.css
|--template
|--index.tpl
|--template_c
in the index.tpl what would be the proper format to access style.css?
would it ../library/css/style.css? or
/project/library/css/style.css?
It depends on what you want to do.
If your goal is to have the browser access the css file, you need to specify the path relative to the document root. so, if your project lies within htdocs, it might be /project/library/css/style.css.
If your goal is to read the CSS within Smarty (say to inline it) you need to specify the absolute file path (e.g. /home/users/foo/project/library/css/style.css)
Accessing files relative to the current template file works with ./file and ../file - but only for {include} and {extends}. Everything else must either be absolute or relative to the CWD (current working directory) of the actually executed script.
Related
I am currently working on getting automatic SCSS -> CSS conversion set up using PyCharm's File Watcher functionality. I am able to have the files output to another directory, but I cannot get them to do it relative to a specific directory. Currently, I have the following settings and relevant file tree:
Tree
|media/
|-c/
| |-css/
| |-folder/
| | |-file2.css
| --file.css
--src/
|-css/
|-folder/
| |-file2.scss
--file.scss
File Watcher Settings
Scope is the media/src/css/ directory and all subdirectories recursively
Arguments is --no-cache --update $FileName$:$ProjectFileDir$/media/c/$FileDirRelativeToProjectRoot$/$FileNameWithoutExtension$.css
Working directory is $ProjectFileDir$/media/src/css/
Output paths to refresh is $ProjectFileDir$/media/c/$FileDirRelativeToProjectRoot$/$FileNameWithoutExtension$.css
With these settings, when I update file2.scss, there is an error stating that media/c/media/src/css/folder does not exist, which is not where I want the file anyway.
The issue that I am having is that I would like to have all paths relative to the working directory root preserved (ie. media/src/css/folder -> media/c/css/folder, but all of my source SCSS files are under multiple folder levels from the project root and the tutorial only specifies how to maintain folder structure if you are compiling directly below the root, not a folder below the root. Does anyone know a way that my folder structure could be preserved so that anything under media/src/css would have the same relative output in media/c/css?
The CrazyCoder posted solution in another Question. It is hard to find, so I'm linking it. https://stackoverflow.com/a/15965088/2047157
Quoting:
The trick is to use $FileDirPathFromParent(dir)$ macro:
I'm having trouble understanding Laravel 5's elixir pathing. In my project, I have multiple css files (bootstrap, plugins, theme etc) and javascript files stored under:
resources/assets/css/<my css files>
resources/assets/js/<my javascript files>
I simply want to combine and version all styles and scripts and place them in my public directory. I believe the default output directly is:
public/build/css/app-xxxxxxxx.css
public/build/js/app-xxxxxxxx.js
(Where xxxxxxxx is the checksum using the version method)
What should my gulpfile.js look like to achieve this? Thanks!
You can use full path on the name or set the third parameter as default path. Examples (works with scripts or css):
mix.stylesIn('resources/assets/css', 'public/css/all.css');
Since there is a bug where you can't use the output of a somethingAll to concatenate with something else, I use this instead (note the wildcard):
mix.scripts(['maskedinput.js',
'blockui.js',
'user/*.js'],
'public/js/user.js', 'resources/assets/js/');
First parameter is the input files, second is the output file, third is the input's default path.
To version just call it on the file path.
mix.version("public/js/user.js");
I need to get the main project working directory, for example I have a project folder structure like,
Projectmainfolder->
SourceCodeFolder
AnotherFolder
I have my all code files in sourceCodeFolder, and now I want to get or print Projectmainfolder path, Kindly let me know if there is a way to get the location path of the root project folder.
This will give you the path to the current file.
__FILE__
In order to expand a relative path, do this:
File.expand_path("../../", __FILE__)
if you start your script from the Projectmainfolder directory, Dir.getwd should print you the path you want. Or did you mean something different?
After running the jammit -c assets.yml -o assets command, Jammit goes through all of my CSS files and changes them around before concatenating everything. It, for some reason, expands the URL() path for all of my #font-face url paths to the absolute path of the file located on my computer. Is there any way to get this to say as an absolute path within the public directory?
I found out the problem. Turns out that the font files were not located in the public directory so jammit was making sure that the path exists outside of that.
Is there any way to specify in .vsprops file paths relative to .vsprops file directory?
For example, I have the followind directory stucture:
largesolution.sln
a/a.vcproj
b/c/c.vcproj
common/common.vsprops
Both a.vcproj and c.vcproj include common.vsprops, and I want to add some macro or set include directory relative to common folder regardless the solution directory both projects are included to. I've tried using $(InputDir) in .vsprops file, but it seems this macro is expanded as directory containing .vcproj, not .vsprops file.
Setting absolute paths or setting global include path in Visual C++ Directories is not a solution because different developers have different location of the source tree root. Setting paths relative to $(SolutionDir) does not suit because it is useful to have smaller solutions containig some subset ob projects (for example, a.vcproj only) somewhere outside main sources tree.
Of course, setting include directory in a.vcproj to $(ProjectDir)..\common works fine, but the result to be achieved is only including .vsprops and having paths set correctly.
You can use MSBuildThisFileDirectory macro.
For example:
You set Include Directories to "$(MSBuildThisFileDirectory)\include;$(IncludePath)" in common.props.
See http://msdn.microsoft.com/en-us/library/vstudio/ms164309.aspx for details.
Tested with MSVS2012 and MSVS2013.