Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ember-link
Advanced tools
Readme
Introduces a new Link
primitive to pass around self-contained references to
routes, like URLs, but with state (isActive
, ...) and methods (open
,
...). Also brings along an accompanying template helper for easy
usage in templates.
ember-link
does to routing whatember-concurrency
did to asynchrony!
Install ember-link
with:
ember install ember-link
You can use ember-link
in a declarative form with a (link)
helper or imperatively with the LinkManager
Service.
(link)
Helper ExampleUse the (link)
helper to create a link primitive and attach it to an element.
{{#let (link "about") as |l|}}
<a href={{l.url}} {{on "click" l.open}}>
About us
</a>
{{/let}}
LinkManager
Service ExampleUse the LinkManager.createLink()
method to create a link programmatically.
import Contoller from '@ember/controller';
import { service } from '@ember/service';
import type { LinkManagerService } from 'ember-link';
export default class PageHeader extends Controller {
@service declare linkManager: LinkManagerService;
aboutUsLink = this.linkManager.createLink('about');
}
The idea of ember-link
is to be able to create link primitives, that you can
pass around. Create links at route level and then pass them into components.
A more in-depth guide is available at using primitives.
ember-link has testing support on board, preparing the environment with
setupLink()
and linkFor()
to create a link to a route on the fly:
import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { linkFor, setupLink } from 'ember-link/test-support';
import type { TestContext as BaseTestContext } from '@ember/test-helpers';
import type { TestLink } from 'ember-link/test-support';
interface TestContext extends BaseTestContext {
link: TestLink;
}
module('`setupLink` example', function (hooks) {
setupRenderingTest(hooks);
setupLink(hooks);
test('using link in render tests', async function (this: TestContext, assert) {
// arrange
this.link = linkFor('some.route');
this.link.onTransitionTo = () => assert.step('link clicked');
await render(hbs`
{{#let this.link as |l|}}
<a href={{l.url}} {{on "click" l.open}}>Click me</a>
{{/let}}
`);
// act
await click('a');
// assert
assert.verifySteps(['link clicked']);
});
});
FAQs
Link primitive to pass around self-contained route references
The npm package ember-link receives a total of 18,376 weekly downloads. As such, ember-link popularity was classified as popular.
We found that ember-link demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.