bdkjones / Kit

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

Is it possible to use a variable in an import/include? #15

Open tschofen opened 7 years ago

tschofen commented 7 years ago

As Kit can't do conditionals, I was hoping to use variables in file path to include a file. I tried:

<!-- $content: content.kit -->
<!-- @include source/shared/$content -->

or

<!-- $path: one -->
<!-- @include source/shared/$path/content.kit -->

Neither works. Perhaps there is a different syntax?

bdkjones commented 7 years ago

It's not possible currently. The syntax would need to involve interpolation, like Sass: {$variableName}

I might be able to implement that in the future, but what's the use case for this? Generally, variables in paths are a workaround for overly-complex project structures. The better approach is to restructure and simplify.

Sent from my iPhone

On Apr 15, 2017, at 16:30, tschofen notifications@github.com wrote:

As Kit can't do conditionals, I was hoping to use variables in file path to include a file. I tried:

or

Neither works. Perhaps there is a different syntax?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

JayHoltslander commented 6 years ago

I asked @bdkjones on Twitter about something similar to this and was told to open a Github issue. Since this existing issue is so similar, I'll just leave this here.

I had asked if it were possible to do something like:

<!-- $variable-en = /en/ -->
<!-- $variable-fr = /fr/ -->
<!-- $variable-de = /de/ -->

<!-- @import "copywriting<!-- $variable-en -->homepage-markdown.html" -->