boostermedia / clopp Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
For example:
<!-- #if __chrome
<script id="booster-api" type="text/javascript" src="../../shared/booster/api.js"></script>
<!-- #elseif __target='dev' -->
<script id="booster-api" type="text/javascript" src="shared/booster/api.js"></script>
<!-- #endelseif
<!-- #elseif __target='prod' || __target='stage'
<script id="booster-api" type="text/javascript" src="/shared/booster/api.js"></script>
<!-- #endeif -->
Say you have this piece of code:
/* #define myDefinition "someString" */
// your code here
myDefinition
Your myDefinition
variable at the end of the file won't be replaced by it's value, "someString"
, because it is at the very end of the file.
Until anybody finds a valid use case for this, I am not really feeling like fixing this... mostly because it is a pain in the ass to fix :)
clopp should handle .ts files "out of the box", which is trivial to do, because it is so like .js. However, a way to configure how to process a new file type would be more generic, and highly useful. Perhaps regular expressions to recognize comments, or some such.
Currently, #includes do not work 100% correctly. They work only "only layer deep".
For example, evaluate this code:
main.js
/* Some random code */
// #include fileA.js
/* Some more random code */
fileA.js
/* Some random code */
// #include fileB.js
// #exclude
/* random code */
// #endexclude
// #if 1+1==2
// Well look at that! 1+1 equals 2!
// #endif
/* Some more random code */
fileB.js
/* Some more random code */
The result of main.js will be this when the preprocessor is completely done with your files:
/* Some random code */
/* Some random code */
// #include fileB.js
// #exclude
/* random code */
// #endexclude
// Well look at that! 1+1 equals 2!
/* Some more random code */
/* Some more random code */
The reason for this is that includes & excludes do not get preprocessed in files that have been #included. All other preprocessor tags (#define, #ifdef, #ifndef, #if, etc) do get preprocessed.
For example:
<!-- #if __chrome
<script id="booster-api" type="text/javascript" src="../../shared/booster/api.js"></script>
<!-- #else -->
<!-- #if __target='dev' -->
<script id="booster-api" type="text/javascript" src="shared/booster/api.js"></script>
<!-- #else
<script id="booster-api" type="text/javascript" src="/shared/booster/api.js"></script>
<!-- #endif -->
<!-- #endif -->
For example this statement is not correctly handled:
var foo = SOMECONFIGPARAM;
where SOMECONFIGPARAM is defined in the context, it will fail to be replaced.
Fix is simple add a semicolon to the expression on line 316:
contents = contents.replace(new RegExp('([ \+\-\\!\|\[\]\'\"\>\<\=\(\)\n\t])(' + prop + ')([ \'\[\]\+\-\(\)\=\\&\>\<\{\};\n\t!])', 'gi'), function (match, pre, include, post) {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.