npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rogain-core-helpers

v0.2.3

Published

Core helpers for Rogain templates.

Downloads

28

Readme

rogain-core-helpers

Core helpers for Rogain templates.

Helpers

Frame

Alias and create inline variables.

<Frame friend={@attrs.name} intro="My friend's name is">
    <div>{intro} {friend}</div>
</Frame>
<Friend name="Buckle" />
<div>My friend's name is Buckle</div>

Children

Provides an outlet in a component that can be used to compose components.

<div class="card"><Children /></div>

Each

Returns a tree of the data mapped to children. Each child can access the current element with the @item (or as attribute) properties and the current index with @index.

<Each data={searchResults} as="@result">
    <h3>{@result.title}</h3>
    <p>{@result.excerpt}</p>
</Each>

Attributes

data

Variable. Array.

as

String. Defines the local variable for accessing each element in data. Defaults to @item.

Defined

Returns children if data is an non-empty Array or Object ([0, 1], {x:1,y:3}) or defined variable. If the <Else /> branch is defined, it will be returned when data is empty or undefined.

<Defined data={searchResults}><Results /></Defined>

Attributes

data

Variable or Expression.

Empty

Returns children if data is an empty Array or Object ([], {}) or undefined variable. If the <Else /> branch is defined, it will be returned when data is non-empty and defined.

<Empty data={searchResults}>No results.</Empty>

Attributes

data

Variable or Expression.

If

Returns it's children if data to value are equal. If the <Else /> branch is defined, it will be returned when data and value are not equal.

If value is not defined, If will have the same behavior as Defined.

<If data={loggedIn} value="true"><Dashboard /></If>

Attributes

data

Variable or Expression.

value

Variable or Expression. Optional.

Unless

Returns it's children if data to value are not equal. If the <Else /> branch is defined, it will be returned when data and value are equal.

If value is not defined, Unless will have the same behavior as Empty.

<Unless data={loggedIn} value="true"><LoginForm /></Unless>

Attributes

data

Variable or Expression.

value

Variable or Expression. Optional.

Range

Returns children if data is between min and max. If the <Else /> branch is defined, it will be returned when data is out of range.

Omitting min or max will default to -Infinity and Infinity respectively.

<Each data={searchResults}>
    <Range data={@index} min="0" max="2">
        <!-- Top 3 -->
        <h2>{@item.title}</h2>
        <p>{@item.excerpt}</p>
    <Else />
        <!-- The rest -->
        <h3>{@item.title}</h3>
    </Range>
</Each>

Attributes

data

Variable or expression.

min

Number. Optional.

max

Number. Optional.

Else

Implicit helper. Can be used with If, Unless, Defined, Empty, Range. Used to denote an inverse branch.

<If data={loggedIn} value="true">
    <!-- If Branch -->
<Else />
    <!-- Else Branch -->
</If>

<Unless data={loggedIn}><Else /></Unless>
<Defined data={loggedIn}><Else /></Defined>
<Empty data={loggedIn}><Else /></Empty>
<Range data={loggedIn}><Else /></Range>

Else helper is not meant to be called as a block, it's used to split trees inside other helpers.

Install

With npm do:

npm install rogain-core-helpers

License

MIT