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

Add variables to textbox in certificate #490

Open
subru-37 opened this issue Oct 10, 2024 · 0 comments
Open

Add variables to textbox in certificate #490

subru-37 opened this issue Oct 10, 2024 · 0 comments
Assignees

Comments

@subru-37
Copy link
Collaborator

Description

In the textbox where we can edit the text, we have to add an option to add variables.

A variable can be denoted in the textbox by, for ex, Hello {{name}}, from {{class}} where name can be Subramani, Asil, Amal etc and class can be eca, csc like that

Hints

so what you'd have to do is just have a state variable in the format:

const [myvars, setMyVars] = {
    textbox1: [],
    textbox2:[] 
}
// where the array would have variables like name, class etc for a textbox  
// to keep track of variables in each textbox

Sample function to detect variables:

const checkVariable = (currValue) => {
    const regex = /{{\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*}}/g;
    const matches = currValue.match(regex);
    if (matches) {
      const newVariables = matches.map((match) =>
        match.replace(/{{\s*|\s*}}/g, "")
      );
      // Add only unique variable names to the state
      setNewHandles((prevVariables) => {
        const uniqueVars = [...new Set([...newVariables])];
        return uniqueVars;
      });
    } else {
      setNewHandles([]);
    }
  };
@subru-37 subru-37 converted this from a draft issue Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants