
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
ember-route-shy-component
Advanced tools
A component that won't render when the application's current route matches a preconfigured condition
A component that won't render when the application's current route is on a blacklist.
Often, an Ember application will have components or visual elements that are meant to be seen in some scenarios
and hidden in others. In many cases, this is handled inherently by having different templates for different routes. In some cases, however, a component that lives in a top-level route -- a navbar, for example -- might need to have its visibility toggled dynamically based upon the current state of the application in a nested child route. ember-route-shy-component helps to handle this.
ember install ember-route-shy-component
The route-shy component dynamically computes its isVisible property whenever the currentRouteName of the application is changed. If currentRouteName corresponds to any of the items in a blacklist -- through either string comparison or regular expression matching -- Ember will set the component's display property to none.
{{#route-shy blacklist=routesWhereNavbarIsHidden}}
{{x-navbar}}
{{/route-shy}}
Because it's meant to be an edge-case utility as opposed to a design driver, route-shy-component operates around a blacklist.
Regular expressions offer a powerful way to control where/when the component will be displayed. Any item in the blacklist that is a regular expression will be tested against currentRouteName. Otherwise, route-shy will attempt to perform a direct string comparison.
An effective approach for setting the list would be to prepare it as bound data -- in any of the places that your template would already be getting its data from.
A super-simplified example of using model data might looks like this:
<!-- application/routes.js -->
model () {
return {
navbar: {
routesWhereHidden: [
'application',
/homepage(?:\.*)/,
/login(?:\.*)/,
/register(?:\.*)/
]
}
....
};
<!-- application/template.hbs -->
{{#route-shy blacklist=model.navbar.routesWhereHidden}}
{{private-navbar}}
{{/route-shy}}
The blacklist could also be set "inline" with a string of spaced-separated names. By default, each name will be treated as a string (i.e, compared directly). You can, however, tell route-shy to treat theses names as regular expressions by setting the forceRegExp attribute to true.
{{#route-shy blacklist="foo bar baz(?:\.*)"}}
{{private-navbar}}
{{/route-shy}}
Note that this is a far less practical approach than having your blacklist data/logic configured outside of the template. And any attempts to have inline strings tested as regular expressions must leave off the / characters otherwise associated within inline RegExp compilation -- as route-shy, internally will need to pass them to the JavaScript RegExp constructor.
As a convenience, route-shy can "sync" the results of its computed isVisible property with a property on a passed in object. This might be useful if another component is attempting to style itself relative to the visibility of components inside of a {{route-shy}} block (e.g., a page component that needs to toggle a padding offset depending on whether its top navbar is visible).
Usage is as simple as declaring an object to syncWith, along with a syncProperty on that object.
{{#route-shy
blacklist=model.navbar.routesWhereHidden
syncWith=model.navbar
syncProperty="isVisible"}}
{{private-navbar}}
{{/route-shy}}
git clone this repositorynpm installbower installember servernpm test (Runs ember try:testall to test your addon against multiple Ember versions)ember testember test --serverember buildFor more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
A component that won't render when the application's current route matches a preconfigured condition
We found that ember-route-shy-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.