bdkjones / Kit

The Kit Compiler, as implemented in CodeKit
77 stars 6 forks source link

Documentation: Fix incorrect statement about variable scope #13

Open toonetown opened 8 years ago

toonetown commented 8 years ago

For example, I'd love to define all my localization strings as variables in a single file (strings.en.kit) and then be able to use them in the parent file (and every other file that the parent imports).

I think that the default behavior should be like it is right now, when you do <!-- @import page -->, but perhaps I suggest a <!-- @importGlobal page --> or something similar (perhaps even to ONLY allow variables when doing @importGlobal...and maybe the file format is just:

$var1: value1
@var2 = value2

Or call the command @importVars or something...I'm not too worried about syntax - I just think it might be nice to have a single include for importing all variables (at least the default values).

bdkjones commented 8 years ago

I'm not sure I understand. This is doable now. Create a strings.kit file, define a bunch of variables and then @import strings.kit in the file where you want to use those variables. Do this at the top of your parent file and those variables will also be available in each child file that the parent imports.

toonetown commented 8 years ago

Ok...that is exactly the opposite of what is documented under "Variable Scope" at https://incident57.com/codekit/help.html#kit

Any variable you declare can be used at any later point. This extends into imported files. If you declare a variable in "master.kit", then import "beta.kit", the variable from "master" will be available in "beta". By contrast, any variables declared in "beta" will NOT be available in "master".

(The last sentence is exactly what I want to do)

But to be honest, I have never really tried it (because of said documentation). Apparently, I'm a blind sheep.

toonetown commented 8 years ago

You are correct. I just verified that you can, for example, create a base file, and then @include the strings file, and then access the variables defined in the strings file from the base file.

I will change the title of this to actually fix the documentation so as not to cause confusion. All that needs to be done (IMO) is following sentence should be deleted (or modified):

"By contrast, any variables declared in "beta" will NOT be available in "master".

bdkjones commented 8 years ago

Yea. I meant that the variables aren't available in the master file before the import statement that brings in beta.

That's standard for every language I know

Sent from my iPhone

On Dec 11, 2015, at 21:30, Nathan Toone notifications@github.com wrote:

You are correct. I just verified that you can, for example, create a base file, and then @include the strings file, and then access the variables defined in the strings file from the base file.

I will change the title of this to actually fix the documentation so as not to cause confusion. All that needs to be done (IMO) is following sentence should be deleted (or modified):

"By contrast, any variables declared in "beta" will NOT be available in "master".

— Reply to this email directly or view it on GitHub.