question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add "namespace" to imported files

See original GitHub issue

I need to add a base class to all rules for imported resources.

I have a project that use bootstrap less files to build an own theme.

I need to “namespace” all rules, to ensure, that the css rules only match in a subtree of document tree.

I tried to wrap all imports with the a base class like this:

 .my-base {
    @import boostrap.less
    @import my.less
}

but than, the “Parent Selectors” with “Changing selector order” makes problems.

Example:

rule in imported less file:

.menu {
  border-radius: 5px;
  .no-borderradius & {
    border-radius: 0;
  }
}

output after wrapping:

.my-base .menu {
  border-radius: 5px;
}
.no-borderradius .my-base .menu {
  border-radius: 0;
}

The second rule do not match anymore!

What I want as result is:

.my-base .menu {
  border-radius: 5px;
}
.my-base .no-borderradius .menu {
  border-radius: 0;
}

The only way I found is to run less two times and produce a temporary css file, that I import in second run like this:

 .my-base {
    @import (less) temp.css
}

But than I got wrong results for CSS calc function.

Input first run:

height: calc(~"100% - " 24px);

Result in temp.css:

height: calc(100% -  24px);

Result after wrapping:

height: calc(76%);

It would be nice, if there would be a way to handle this in one run.

May be with a special import option to prevent the “Changing selector order” of “Parent Selectors” to go outside an import or a global option for less that it can add a base class to all css rules after regular processing.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
seven-phases-maxcommented, Feb 19, 2016

@mathieumg The label roughly means “the feature should not or cannot be implemented in the core, but can be supported via plugin”.

0reactions
stale[bot]commented, Nov 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp.net - How to add namespace in aspx file?
How i can add nampespace to aspx file i have tried <%@ import namespace="Westwind.Tools"%> but it does not work? asp.net.
Read more >
Create namespaces | Maya 2018
Create namespaces when referencing or importing · In the parent file, select File > Create Reference > . · In the Namespace Options,...
Read more >
Namespaces and XML Schema Import - 7.3
The XML schema import automatically creates a namespace container to hold the namespaces found in the imported XML schemas. The name of the...
Read more >
Code Syntax Style: Namespace Imports - ReSharper
In each of your source code files, you should have the right set of namespace imports ( using directives in C#). If an...
Read more >
Using namespaces: Aliasing/Importing - Manual
This is similar to the ability of unix-based filesystems to create symbolic links to a file or to a directory. PHP can alias(/import)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found