Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unit test. Fixed #170 #171

Merged
merged 1 commit into from
Feb 26, 2016
Merged

Fixed unit test. Fixed #170 #171

merged 1 commit into from
Feb 26, 2016

Conversation

kontsevoy
Copy link
Contributor

No description provided.

klizhentas added a commit that referenced this pull request Feb 26, 2016
@klizhentas klizhentas merged commit ccd98a3 into master Feb 26, 2016
@klizhentas klizhentas deleted the ev/170 branch February 26, 2016 23:51
nick-inkeep pushed a commit to nick-inkeep/teleport-docs that referenced this pull request Jun 20, 2023
* Add support for basic named params in partials

Closes gravitational#165

Allow a partial inclusion expression, e.g., `(!mypartial.mdx!)` to
assign named parameters that replace template variables in partials. For
example, `(!mypartial.mdx var="value"!)` replaces the template variable
`{{ var }}` in `mypartial.mdx` with `value`.

Design details:

- Variable values must be in quotes, single or double, and the quotes
  must match.

- There can be multiple variables/values. The inclusion expression
  separates these with spaces, e.g.:

  ```
  (!mypartial.mdx var1="val" var2='val'!)
  ```

- Allows for default parameter values, which will make it easier to add
  parameter support to existing partials. E.g., with a template variable
  like this:

  ```
  {{ myvar="myval" }}
  ```

  This partial will populate the template variable with `myval` at this
  particular location if the inclusion expression does not assign it a
  value.

- If a parameter does _not_ have a default value, and an inclusion
  expression does not provide one, the `{{ myvar }}` expression will be
  left untouched, allowing for situations where a partial needs to
  include a literal `{{ }}` string.

- Escapes: Unfortunately, due to some JavaScript quirks I didn't give
  myself time to look into, quotes must be escaped twice, e.g., `\\"`.
  Double escapes are removed within double-quoted strings but not within
  single-quoted strings.

* Respond to PR feedback

- Simplify parsing by requiring values in double quotes and single
  spaces between assignments. Split include expressions in order to
  parse assignments.

- Implement a new design in which a partial must declare default
  parameter values in the first line. Uses "{{" to indicate defaults so
  we can reserve "(!" for including partials and "{{" for syntax having
  to do with partial parameters.

- This also fixes the tests for parameter parsing, since previously
  failures to throw as expected would not trigger test failures.

* Add a comment

* Get tests to pass for Node 14

remark-includes was using replaceAll, which is only available beginning
in Node 15.0.0. The gravitational/docs CI environment uses Node 14.
nick-inkeep pushed a commit to nick-inkeep/teleport-docs that referenced this pull request Jun 20, 2023
Closes gravitational#191

The `markdown-lint` script includes all files in `docs/pages/includes`.
The script also processes partial inclusion expressions within docs
pages, then lints those pages. This means that partials are linted at
least twice: once on their own and for every time they are included in a
docs page.

The first lint pass for each partial usually works as expected.
However, there is an issue if a partial includes a default parameter
value (gravitational#171), like this:

```
{{ var="default value" }}

Here is a variable with a {{ var }}.
```

When a page includes this partial, the docs engine removes the first
line before inserting the resolved text. As a result, partials with
default parameters render as expected and pass the linter within their
including pages.

But when we run the `markdown-lint` script, and the linter checks the
partial on its own, the first line remains in the partial. This causes
the linter to return an error.

This change edits the `markdown-lint` script to ignore files within
`docs/pages/includes`. This will allow us to use partials with default
parameter values without them breaking CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants