totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

RESOURCE does not work properly #572

Closed bkhurram closed 7 years ago

bkhurram commented 7 years ago

Hii, RESOURCE not found key when key is uppercase:

@{RESOURCE( "res-file", "key.UpperCase" )} NOT WORK @{RESOURCE( "res-file", "key.uppercase" )} WORK

res-file

key.UpperCase : KEY UpperCase FOUND
key.uppercase : KEY lower case FOUND

and when i use command !RESOURCE i have an error self.RESOURCE is not a function

this error i have fix in this way:

from:

        case '!resource':
        case '!RESOURCE':
            return '$STRING(self.' + command.substring(1) + ')';

to:

        case '!resource':
            return '$STRING(self.' + command.substring(1) + ')';
        case '!RESOURCE':
            return '$STRING(self.' + command.substring(1).toLowerCase() + ')'; 
petersirka commented 7 years ago

Hi, of course, it's case-sensitive as configuration too. My rule: use everytime lower-case chars.

bkhurram commented 7 years ago

see this:

@{resource( "res-file", "key.UpperCase" )} WORK
@{RESOURCE( "res-file", "key.UpperCase" )} WHY THIS NOT WORK ( empty string ) and previous line work

@{!RESOURCE( "res-file", "key.UpperCase" )} give me an exception  "Error: View "/it/home/index": !RESOURCE( "res-file", "key.UpperCase") - Line: 10 - self.RESOURCE is not a function"

res-file key.UpperCase : KEY UpperCase FOUND

petersirka commented 7 years ago

OMG, you're right. 100x sorry, my mistake. I have fixed it, try $ npm install total.js@beta.

Thank you 💯 🥇

bkhurram commented 7 years ago

now it's not work @{!resource( "res-file", "key.UpperCase" )}

        case '!resource':
            return '$STRING(self.' + command + ')';

i think you forget to add .substring(1)

this code work:

        case '!resource':
            return '$STRING(self.' + command.substring(1) + ')';
petersirka commented 7 years ago

OMG! I'm fucker. Thank you again. Please reinstall beta again.

bkhurram commented 7 years ago

It works well.

petersirka commented 7 years ago

Great! Thank you again!

bkhurram commented 7 years ago

Thank you very much for the quick fix