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

Passing Calling Record Information #28

Open
ptth222 opened this issue Jun 22, 2023 · 1 comment
Open

Passing Calling Record Information #28

ptth222 opened this issue Jun 22, 2023 · 1 comment

Comments

@ptth222
Copy link
Collaborator

ptth222 commented Jun 22, 2023

This kind of goes along with nested directives, but I wanted it to have its own issue. Basically, when a nested directive is called you usually want to pass the record information that the calling directive was on when it called the nested directive. For example, if you have a directive that is looping over sample records and creating a dictionary based on the data in the sample records and it calls another directive to fill in a header value, you want that nested directive to have immediate access to the sample record's information. I have already exposed this in the code, but I think you had an issue with my initial syntax. My suggestion was to use the '^' character to indicate that you want the field from the record that called the directive. For example:

"studies%factors": {
    "no_id_needed": {
        "value_type": "section_matrix",
        "required": "True",
        "test": "study.id=^id",
        "headers": [
          "\"@id\"=\"#factor/\"id",
          "\"factorName\"=id",
          "\"factorType\"=/studies%factor%type",
          "\"comments\"=/studies%factors%comments"
        ],
        "table": "factor"
        }
    }

The "^id" in "study.id=^id" for the "test" field would indicate to fill that in with the record's "id" value. You suggested '$' instead of '^' to help avoid confusion with regex, but '$' is also a regex character. Also there are no regexes in the directives currently, and if they were added I would expect them to have a similar syntax as what's in the modification tags, i.e r"...". I really like the caret because it is often used to indicate something above, like it's pointing up, and in this case it would be like pointing up the call stack.

What's the final opinion on the syntax?

@hunter-moseley
Copy link
Member

hunter-moseley commented Jun 23, 2023 via email

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

No branches or pull requests

2 participants