Import less files within the scope of a mixin - import

Im researching for this a while now, but i cant figure it out.
#theme: 'example';
// works
#import (reference) "../themes/#{theme}";
.import(#theme) {
// doesn't work
#import (reference) "../themes/#{theme}";
}
i guess the mixins get called at the "end" of the compiling process, so it cant import there because it needs the variables earlier.
is there some known hidden secret workaround for this?
this code
.import(#theme) {
// doesn't work
#import (reference) "../themes/#{theme}";
}
.import(hello);
failed because of
SyntaxError: variable #theme is undefined in less/capsule.less on line 33,

Related

NetSuite SuiteScript - Constants And Inclusion

I have a NetSuite SuiteScript file (2.0) in which I want to include a small library of utilities I've built. I can do that fine, and access the functions in the included library. But I can't access the constants I've defined in that library - I have to re-declare them in the main file.
Here's the main file:
define(['N/record', 'N/search', './utils.js'],
function (record, search, utils) {
function pageInit(scriptContext) {
isUserAdmin = isCurrentUserAdmin(contextRecord);
if (isUserAdmin) {
alert('Administrator Role ID is ' + ADMINISTRATOR_ROLE);
// Do something for Admin users
}
return;
}
return {
pageInit: pageInit
};
});
You can see I include the file ./utils.js in it. Here's utils.js:
const ADMINISTRATOR_ROLE = 11;
function isCurrentUserAdmin(currentRecord) {
return ADMINISTRATOR_ROLE == nlapiGetRole();
}
That's the entire file - nothing else.
In the main file, the call to the function isCurrentUserAdmin works fine. It correctly tells me whether the current user is an admin. Note that I don't have to preface the call to isCurrentUserAdmin with utils. (utils.isCurrentUserAdmin doesn't work - it gives me the error JS_EXCEPTION TypeError utils is undefined). But when the code gets to the line that uses ADMINSTRATOR_ROLE, I get the error JS_EXCEPTION ReferenceError ADMINISTRATOR_ROLE is not defined. BTW, if I put the constant definition of ADMINISTRATOR_ROLE in the main file instead of utils.js, I get the same error when utils.js tries to use it. The only way I can get it to work is if I have the line defining the constant in both files.
Why does the inclusion work for the function, but not the constant? Am I including the library wrongly? I thought I'd have to use it as utils.isCurrentUserAdmin rather than just isCurrentUserAdmin, but to my surprise that's not the case, as I say above.
If you have utils.js like below, you can use utils.ADMINISTRATOR_ROLE and utils.isCurrentUserAdmin() in your main file.
/**
*#NApiVersion 2.0
*/
define ([],
function() {
const ADMINISTRATOR_ROLE = 11;
function isCurrentUserAdmin() {
// check here
}
return {
ADMINISTRATOR_ROLE: ADMINISTRATOR_ROLE,
isCurrentUserAdmin: isCurrentUserAdmin
};
});
Try
define(['N/record', 'N/search', 'SuiteScripts/utils']
You need to make sure any member you need to access in another module needs to be exported in the source module using the return statement

using java annotations in rythm template engine

In the quest of getting JUnit tests to be part of how we use Ryhtm we came up with the code snippet below. All went well until we added
#Test
which obviously is a java annotation and uses the # marker as a syntax element that is also being used by Rythm. How can the desired effect be achieved to get the #annotation? To simply escape the ## does not work it gives a
Syntax error on token "#", delete this token
error. So How can a Java # annotation be used ?
I have also filed this as a bug report at https://github.com/greenlaw110/Rythm/issues/285
#// This is a rythm template
#import static org.junit.Assert.*
#import org.junit.Test.*
#def static {
class TestMe {
String name;
#Test
public void testMe() {
name="test";
assertEquals("test",name);
}
}
}
#{
TestMe testme=new TestMe();
testme.name="testme";
}
The TestMe has the name #(testme.name)
If you use a fully qualifying annotation it should work:
#org.junit.Test
#import org.junit.Test.* in your template code should be #import org.junit.Test, note that .* needs to be take off

Play 2 template not recognizing code, printing it instead

I am trying to output the items in a List object to XML on the screen using Scala. I am trying to use the following code:
#(suppliers: List[Supplier])
#import helper._
#import scala.xml._
#main("Suppliers and Parts") {
var xmlSuppliers = <suppliers>{ suppliers.map(s => s.toXml()) }</suppliers>
println(xmlSuppliers)
}
But all that is happening is that those two lines of code are being written literally to the screen. They are not being interpreted.
I'm able to access the values of the suppliers list if i'm just using #supplier.id #supplier.name, etc. but i am wanting to output the List to XML on the screen and it's just not happening for me.
Thanks in advance.
You should either to wrap your code in a #{} block, or rewrite your code the template way:
<suppliers>
#suppliers.map { s => #s.toXml() }
</suppliers>

Duplicate symbol

I recently added some openfeint code to my classes and changed them to .mm
All of a sudden I get errors that duplicate symbols are found in the object files when building.
ld: duplicate symbol _audioPlayer in blah blah /Objects-normal/i386/Stage2.o and /Users/blah blah .build/Debug-iphonesimulator/blah.build/Objects-normal/i386/Stage1.o
Why is it suddenly causing this error? What exactly is the error?
I have variables with the same name in different classes, it should be a problem?
Thanks
You're probably declaring two variables with the same name in global scope (not inside interfaces), and the linker is complaining about that.
This error can also occur if you import a .m file instead of .h.
#import "SomeClass.m"
The short answer is that you can suppress this error with a command line argument to gcc:
-Wl,--allow-multiple-definition
If you implement your method like below in .mm file, duplicate symbol errorwill occur.
#import <Foundation/Foundation.h>
class CppTestOne
{
public:
void Test();
// {
// NSLog(#"Hello C Plus Plus");
// }
};
void CppTestOne::Test()
{
NSLog(#"Hello C Plus Plus");
}
then you can implement your method by
#import <Foundation/Foundation.h>
class CppTestOne
{
public:
void Test()
{
NSLog(#"Hello C Plus Plus");
}
};
//void CppTestOne::Test()
//{
// NSLog(#"Hello C Plus Plus");
//}
more details for this error not clear

error: expected specifier-qualifier-list before 'SearchViewController'

i have a search view controller like below.
#interface SearchViewController : {
TopicRulesViewController *TViewController;
}
i want to move to another view.but i am getting this "error: expected specifier-qualifier-list before 'TopicRulesViewController'"
what is that error?
thanks in advance
You are missing a superclass after the :
You need to import header where TopicRulesViewController class is declared, or, even better - use forward declaration in header file and import necessary header in implementation file:
//header
#class TopicRulesViewController;
#interface SearchViewController : UIViewController{
TopicRulesViewController *TViewController;
}
//m-file
#import "TopicRulesViewController.h"
...
P.S. You also miss superclass for SearchViewController class, but that produces different compiler error so I assumed that that was just a typo...