I am trying to adapt a perl script that is used to generate a splash page for a public wifi installation. I was only given a couple example files to work from and no documentation. After several hours on the phone with the access point vendor I was told I could "just edit" the examples in order to design our custom page. I am trying to understand what is going on in the files.
I have .css file with the following in it.
#logo_container {
width: 528px; height: 58px;
background-image: url(${imagepath}body_title_line.gif);
border: 0;
}
I also have a .pl file with a variable $html_body_top containing the following snippet of html:
Acceptable Use Policy
What does the ${imagepath} refer to? Can I get at it?
I guess the root directory of your images. So if body_ title_line.gif is under /images/ the imagePath variable will probably need to reflect this.
CSS does not support variables so this is something injected by your PL script.
It's possible that's a variable substituted by Template Toolkit, not by your Perl script.
It's also possible the Perl script isn't using strict and, due to lack of declaration of the variable, is substituting a blank string in place of ${imagepath}.
Looks like a token that will be replaced by some sort of build script that runs over all the files in the project.
I would guess that imagepath is a variable from the perl script, replaced at generation time with the actual URL.
Looks like the perl script needs to be run with some value of $imagepath.
${imagepath} is equal to the variable $imagepath. The braces are generally used when variables are used in a string, to remove ambiguity
Related
Are this "*" mean anything like "." or ".." when we define path? I am not getting what those means. Why can't I specify the path in the usual way? I wanted to use paths like "../../XYZ" or something like that. But where is this asterisk coming from and what does it mean? Can I define the path in tailwind without using the asterisk?
If anyone can help I would be most glad. I am new to tailwind CSS so a little bit confused. Thank you.
The asteriks are used for dynamic imports for if you want Tailwinds to scan for content in any folder that is under ./src/ (asuming you are using ./src/**/*.{html,js} as content in tailwinds.config.js file. That means if you use ./src/**/*.{html,js}, the first two ** will look for any folder inside ./src, including subfolders.
So, for example, file path in your configuration file will most likely look like:
./src/**/*.{html,js}
./something-else/**/*.{html,js}
And these configured paths will "translate" to something like:
./src/folder1/file.html
./src/folder1/file.js
./src/folder1/subfolder/file.js
./something-else/folder1/file.html
./something-else/folder1/file.js
etc..
Which means if you add a file with the .js or .html extension in the specified folder(s), Tailwinds will automatically include these files in your project.
According to the documentation, you don't want to use really broad path configurations like /**/*.{html,js}' but rather use something like:
./components/**/*.{html,js}
See the Tailwinds content configuration documentation for more examples.
you can use * to match anything except slashes and hidden files,
and use ** to match zero or more directories.
check this site it will help you:
https://tailwindcss.com/docs/content-configuration
I am working with a framework written in .NET and I do not know .NET. I just need to change this one line where it checks to see if a variable exists, and I need to change it to instead just check on the server to see if the file itself exists.
Here is what is there now:
#if (!string.IsNullOrEmpty(Model.DrawingLink2){
Is this the correct code to change it to check if the file exists instead?
#if (File.Exists(/Portfolio/#(Model.FileNumber)/Images/Large_#(Model.FileNumber)_1.jpg))
You need to map that file, relative to the root of the web application, to the physical file system. You can use HttpServerUtility.MapPath for that. You also need quotes around string literals. The process running the code also needs read access to the directory (very likely the case, just mentioning it to be complete).
#if (File.Exists(HttpServerUtility.MapPath("/Portfolio/#(Model.FileNumber)/Images/Large_#(Model.FileNumber)_1.jpg"))
I'm using Grunt and Assemble to create precompiled templates on my site but I need to dynamically create some sections based on information stored in client-side storage. Is there a way to exempt sections of a template from precompilation?
We can't do custom delimiters (a shortcoming of Handlebars), but there are a couple of solutions that might work for you. Neither is necessarily idiomatic, so you be the judge of how suitable these are for the project you're working on.
string replacement
You could use some custom (temporary) delimiters for the templates in the content that shouldn't be compiled, then create a block helper that will convert those delimiters back to valid handlebars expressions during compile time (I tested this for this answer and it works):
For example:
Handlebars.registerHelper("raw", function(options) {
return options.fn(this).replace(/\[\[/g, '{{').replace(/\]\]/g, '}}');
});
Then use it like this:
{{#raw}}
{{> foo }}
{{/raw}}
Inside foo.hbs, you might have something like this:
<title>[[title]]</title>
and it will render to:
<title>{{title}}</title>
This solution is hacky for sure, and you might have problems if you happen have any code examples embedded in the included content and one of the examples happens to have that syntax (like [0,1,[foo, bar]].
escaping
This solution is most likely the better way to go. Handlebars will not evaluate any templates that are preceded by \. So you can do this:
<title>\{{title}}</title>
and it will render to:
<title>{{title}}</title>
The first suggestion probably wasn't even worth adding, but hey, you never know right?
I am working on adding a mulit-language feature to an asp classic site. I was trying to do this by using if else statements to select the include I want to load. After a bit of research I found out that includes files are loaded up before any code is handled.
How can I get around this issue and load up the proper include files? Is there a better way of doing this?
Thanks!
You can't, as you've discovered, dynamically choose includes. Includes are handled statically before any script is executed.
The next best thing is Server.Execute. You can use logic to choose what additional files to execute, however whether this fits with your solution is another matter. What do your includes currently contain?
Another approach would be place your "multi-language" choices in some data format such a set of CSV files or XML files. Your code would then load the appropriate "language file".
After countless hours I think I finally came up with a solution. I create xml files for each language (en.xml, fr.xml) with a super simple structure (just a label element with an id and value).
By using an attribute that has a similar name to the label I want to replace I can figure out where everything needs to go, and just pull the value.
I'm not sure if this idea helps, but you could dim the language string variables in one ASP file and then set the variables in separate ASP functions. Then your if statements can call the proper function to set the ASP language string variables. You would not be breaking out the language string into separate files, but it might accomplish what you are trying to achieve.
For example:
dim str1, str2
sub SetLangX
str1 = "String val 1 for lang X"
str2 = "String val 2 for lang X"
end sub
sub SetLangY
str1 = "String val 1 for lang Y"
str2 = "String val 2 for lang Y"
end sub
It can be done - just use include virtual instead of file
edit
I stand corrected - obviously i tried too hard to forget those dark ages.
Years ago i worked on a project where we would create a "container page" for every language version an then include the respective portion of constants.
A working spinoff is still running and if you check the page source of this site you can get an idea how we plugged the pages together.
Some of the included scripts identified by their SVN id tags even included more scripts and maintaining this slowly turned into a nightmare.
I'm sorry i was wrong about the conditional include and there should be a better solution than the one mentioned above.
Say I have a project that I am deploying at
www.foo.com/path1/default.aspx
and
www.foo.com/path2/default.aspx
What would be the most reliable way to know if I was in the folder "path1", or "path2"? Can I grab that directly, or do I need to split() somehow on the Request.Url.AbsolutePath, or... ?
I just want to change colors, etc. based on which folder the user is in.
Thanks for any assistance!
If you want to code that logic directly into the page, then yeah, I'd go with split() on Request.Url.AbsolutePath.
That said, I'd consider storing this kind of setting in the AppSettings section of web.config. That way if you decide to change the color in path2, you just need to edit the web.config for path2. If you need to add a new path, just deploy there and edit the web.config as appropriate.
Yeah use Request.Url.AbsolutePath.
I do it to create Breadcrumbs, using Split to split the URL, then in your case I suggest to use Switch statement to change color based on the case of the Switch statement
Here is a great article about Paths in ASP.
Check out the MSDN docs on System.IO.Path. It contains a number of useful functions for dealing with path names. You can get GetDirectoryName() or GetFullPath() or GetFileName() or GetFileNameWithoutExtension().