Skip to content

Allow apidocs helper to accept an array #1

@tunnckoCore

Description

@tunnckoCore

Hi! I'm just trying to create a condition. If src/index.js exists call apidocs for it and then if not exists check if index.js on root exists and call apidocs.

I tried ifExists helper, but it not worked as expected. Even always returns (somehow) truthy value. I expect (as read the code too) to return empty string if file not exist.

So the snippet in that if shouldn't be rendered, but it is.

{% if (ifExists('./src/inxxxxxxxxxdex.js')) { %}
## API
Review carefully the provided examples and the working [tests](./test.js).

{%= apidocs('src/index.js') %}

{% } %}

Even with .length (which is surely falsey value, negative) it still renders the block that is inside the if.

But even if it worked, it still be better if apidocs support such feature by default. What i imagine

## API
Review carefully the provided examples and the working [tests](./test.js).

{%= apidocs(['src/index.js', 'index.js']) %}

So when src/index.js not exist, it will continue to the next one until it find existing file.


Also tried with require helper to require the fs and call existsSync but it throws that it's not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions