I have a palette of colors set as SASS variables. Can Coffeescript access these variables?
SASS
$red: #f00
Coffeescript document.p[0].style.color = $red
My objective is to rely on the color variables as much as possible as they enforce consistency in the UI.
Here's how I would try to do that:
Use a bundler to compile .coffee and .sass in the same environment (I use hem, with .stylus files for css and .coffee for javascript)
Define a .coffee file who contains color constants
Hack a bit the css compilation (LESS/Stylus/SASS) in hem (very readable source code don't worry) to append the variables definitions in the beginning of the files:
varablesDef = yourJsVariables to SASS
compile (variablesDef + originalFile)
Perhaps it's not the ideal solution for you but I think the key is to define variables in JS not trying to access them from your css format.
Related
I wrote a plugin for babel that relies on the opts.filename and opts.filenameRelative properties. It seems to be working within babel-loader for the purposes of analyzing the adjacent files, but the filename itself seems to be modified.
I'm wondering if theres a way, using babel-loader, to get access to the full source file path to use for generating a legible id and hash.
babel-loader does indeed pass the filename into the transform function. In my particular case, I was preprocessing typescript files with awesome-typescript-loader, and that was messing with the file path.
.rkt is the conventional file extension for 'regular' Racket source code. In the documentation, I also see .rktl and .rkts being used. What are .rktl and .rkts used for, and are there any more Racket filename extensions I am not aware of?
The .rkt file extension is generally used for files that represent modules. These normally have a #lang .... line at the top, or sometimes (module ....). They can be imported as modules with require.
The .rktl and .rkts file extensions are used for files meant to be loaded at the top-level that aren't modules. They don't necessarily have a #lang .... line at the top, and must be loaded in some external environment with load instead of imported with require. These usually have a more "dynamic" feel to them, and they're used more often with scripts that use mutation of variables across multiple files. This is not the "encouraged" style in Racket.
The .rktd file extension is used for files that just have data encoded as s-expressions, not code. These files should not be required or loaded (they should not be executed as code). However, other programs use them to store data on the file system using write, and to read the data later using read. Its purpose is the same as a .sexp file or a .json file, just pure data.
I want to switch the GUID I use for an activex control based on if its a 32 bit control or a 64 bit. I would rather not have two .rc files to do this. However resource compiler ignores my pre-processor definitions inside BEGIN - END blocks and always defaults to the Control in the #else section. Please let me know if there is a better way to do this other than having two different resource(.rc) file.
BEGIN
#ifdef _Win64
CONTROL "",IDC_TCHART1,"{FCB4B50A-E3F1-4174-BD18-54C3B3287258}",WS_TABSTOP,0,15,445,199
#else
CONTROL "",IDC_TCHART1,"{FAB9B41C-87D6-474D-AB7E-F07D78F2422E}",WS_TABSTOP,0,15,445,199
#endif
END
I think it doesn't recognise pre-processor symbols defined in project properties for the compiler options, you would need to add this to the Resources properties too. Also, you can #include a file that contains a #define'ed symbol instead.
So as MSDN says :
To define symbols for your resource identifiers, use the #define
directive to define them in a header file. Include this header both in
the resource script and your application source code. Similarly, you
define the values for resource attributes and styles by including
Windows.h in the resource script.
RC treats files with the .c and .h extensions in a special manner. It
assumes that a file with one of these extensions does not contain
resources. If a file has the .c or .h file name extension, RC ignores
all lines in the file except the preprocessor directives. Therefore,
to include a file that contains resources in another resource script,
give the file to be included an extension other than .c or .h.
Having said that, it's highly likely that as soon as you modify this with the Visual Studio resource editor, you'll lose your changes.
I ran into the same issue. Turns out, the documentation here http://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.100).aspx is wrong.
It worked for me to use #if defined(FOO) instead of #ifdef FOO. I use Microsoft Visual Studio 2010.
I am pretty sure VS will overwrite these changes if you make changes in the Resource Editor.
In order to pass a preprocessor definition to the resource compiler you must also define it in the project settings (Config Properties -> Resources -> General).
I'm using Doxygen to generate documentation for some code. I have a large makefile with a lot of OPT+=-DSOME_OPTION that I want to Doxygen to take into account when it analyses the code, since parts of the code are conditionally compiled.
I know there is a an option PREDEFINED in the Doxygen configuration file that specifies macro names that are defined for the preprocessor, but I do not want to manually update this list every time a change happens in the makefile. In essence I want to set the PREDEFINED option to scan the makefile for compilation definitions and be automatically updated.
Is this possible with Doxygen?
I have a src/templates/ directory full of mustache templates. How would I combine and minify the contents of those, so they're available for use in my CoffeeScript app?
I'm already following the directions at https://github.com/jashkenas/coffee-script/wiki/%5BHowTo%5D-Compiling-and-Setting-Up-Build-Tools for combining and minifying my CoffeeScript src into js.
First off, I'll assume that your templates are being exported to the global object (e.g. each one does window.userpane = rather than just userpane =). That's the most important thing. If you're doing that, and you're concatenating and compiling successfully, then the only thing left is to have automatic minification after each concatenation.
Short answer: There's no good tool for this yet. Your best option is to extend your existing Cakefile with a line like
fs.watchFile 'concatenated.js', ->
exec 'uglifyjs concatenated.js'
(To install UglifyJS, run npm install uglify-js.)
Now, this won't solve the problem of ensuring that your scripts are concatenated in a sensible order. (For instance, if you have window.templates = {} in file A and templates.userpane = in file B, then it's very important that file A be concatenated before file B.) For that, you should keep an eye on Sprockets, which lets you indicate at the top of each JS file what its dependencies are, then combine them in an order that respects those dependencies. The creator of Sprockets, Sam Stephenson, is an active member of the CoffeeScript community, and first-class support for CoffeeScript in Sprockets is coming in Sprockets 2 (repo here).
Update: Here's a Cake task to do the actual reading and concatenating of everything in the template directory:
templateJs = ''
files = fs.readdirSync 'template'
for file in files
contents = fs.readFileSync file, 'utf8'
name = file.replace /\..*/, '' # remove extension
templateJs += "window.#{name} = '#{contents}';"
Then prepend your concatenated JS with templateJs. Note that this assumes that there are no single quotes (') in the template. Either put backslashes in front of them or consistently use double quotes.