Is there an equivalent way in Clojurescript to get ns-map, ns-public etc and find what namespaces are available ?
It looks there isn't, apart from using goog.globals via Javascript
Related
I running a mediawiki and want to use syntax highlighting. I am using the extension https://www.mediawiki.org/wiki/Extension:SyntaxHighlight for that.
That works pretty fine.
Alas I want to highlight a language that is not part of this extension. So I wrote an python egg to extend pygments so it can parse my language (using entry points). This works fine.
Now I am struggling to get both to work together. How do I tell the GeShi Extension of MediaWiki to use my pygments extension? What do I have to do, so that using <syntaxhighlight lang="myLanguage"> will result in using my language lexer and style?
The solution was quite simple. One has to edit the file SyntaxHighlight_GeSHi.lexers.php and add the lexer.
It's important to use only lowercase for the lexer name, otherwise the extension will not find the lexer.
The only way I know to realize that a method or property access is missing an externs declaration is by using advanced mode compilation and then testing the result very carefully. Is there a better way?
I have two general rules to handle this issue. Most of the problems should be avoided by applying these rules.
Generate externs.js using generator solve the issues caused by external libraries
Use aget, aset to interact with non-clojurescript js object. Use .-property in clojurescript managed js object.
http://squirrel.pl/blog/2013/03/28/two-ways-to-access-properties-in-clojurescript/
Some Generators are exists.
http://michaelmclellan.me/javascript-externs-generator/
In cases, you need more information
https://github.com/cljsjs/packages/wiki/Creating-Externs
there is a trivial sample gist of using clojurescript with Sencha. I thought clojurescript was designed with first-class interop with javascript libraries in mind, but the more I read the more it seems that only Google Closure is a first class citizen to clojurescript, and interop with other javascript frameworks isn't important to them.
i see no reason why it can't work, am i missing something? i don't want to be 2 or 3 weeks into a prototype before giving up due to problems i can't forsee.
You can use any external JavaScript library. The main issue - if the library doesn't provide an externs.js, then you'll have trouble compiling your ClojureScript with the external library under advanced compilation. That may or may not matter for your use case.
Can we use MooTools AND Prototype & script. aculo.us, both in single project ?
Is there any problem occurs if we use both framework in single project ?
Is there any adapter, which help us to use both framework in single project ?
No, cause both mootools and prototyp extending native javascript objeccts like string and array.
The last script will override the extending the first scrript does. So both frameworks have an Array.each function, and if an script. aculo.us script try do use each but mootools was inserted after prototyp script. aculo.us will use mootools each. Maybe it works but you cant trust anything.
I don't know any adapter.
Btw it isn't a good idea to mix frameworks. First there is an overhead in script load. Second the every framework is build with an specific goal in mind, like jquery is more dom related and easy to use, mootools prototyp are more in the oop business, they all cover most common task. So there is no need to have more then one solution for array.each.
You can try using Prototype and Mootools side by side, because recent MooTools version includes the mechanism which detects the existence of $ function.
However there is very little point in using both frameworks in one project - both have simillar capabilities (extensive DOM manipulation and some goodies which extend JS core like OOP).
I found both frameworks quite simillar, and honestly if one of them can do something - the other one can surely do it as well.
I'd like to know what is the most efficient way of handling properties in Scala. I'm tired of having gazillion property files, xml files and other type of configuration files in Java and wonder if there's "best practice" to handle those someway more efficient in Scala?
Why would you have a gazillion property files?
I'm still using the Apache commons Digester, which works perfectly well in Scala. It's basically a very easy way of making a user-defined XML document map to method calls on a user-defined configurator class. I find it extremely useful when I want to parse some configuration data (as opposed to application properties).
For application properties, you might either use a dependency injection framework (like Spring) or just plain old property files. I'd also be interested to see if Scala offers anything on top of this, though.
EDIT: Typesafe config gives you a simple and powerful solution for configuration - https://github.com/typesafehub/config
ORIGINAL (possibly not very useful):
Quoting from "Programming in Scala":
"In Scala, you can configure via Scala code itself."
Scala's runtime linking allows for classes to be swapped at runtime and the general philosophy of these languages tends to favour convention over configuration. If you don't want to deal with gazillion property files, just don't have them.
Check out Configgy which looks like a neat little library. It includes nesting and change-notification. It also include a logging library.
Unfortunately, it didn't compile for me on the Mac instances I tried. Let us know if you have better luck and what you think...
Update: solved Mac compilation problems. See this post.