Coder Social home page Coder Social logo

paw-regexdynamicvalue's Introduction

Build Status

#Regex Dynamic Value (Paw Extension)

A Paw Extension to match and replace a pattern in an input string. It uses the JavaScript replace method, so the regular expression syntax must follow the JavaScript syntax (see RegExp object).

Installation

Easily install this Paw Extension: Install Regex Dynamic Value

Development

Build & Install

npm install
cake build
cake install

Watch

During development, watch for changes:

cake watch

##License

This Paw Extension is released under the MIT License. Feel free to fork, and modify!

Copyright © 2014 Paw Inc.

##Contributors

See Contributors.

paw-regexdynamicvalue's People

Contributors

mittsh avatar

Stargazers

zuozuo avatar EggsBlue avatar Nickolas Burr avatar Hyunseok Cho avatar Jay Allen avatar Quentin Rousseau avatar

Watchers

James Cloos avatar Quentin Rousseau avatar  avatar Justine De Caires avatar Natalia Panferova avatar  avatar

Forkers

gaulim

paw-regexdynamicvalue's Issues

Dynamically change input fields based on values of other inputs

Hello,

I'm working on a dynamic value extension that outputs a date string with RFC 3339 format strings. I'd like to offer the ability to input custom strings as well as choose from a list of presets. I have a radio button to switch between the two options but I can't figure out a way to dynamically switch between a text entry input field and a dropdown. Where do I write the logic to change the input fields? I've attached my code below:

var moment = require("moment.js")

var inputFields = {
  "choiceRadioButtons": InputField(
    "format",
    "Format",
    "Radio",
    {
      "choices": {
        "radio-preset": "Preset",
        "radio-custom": "Custom"
      },
      "defaultValue": "radio-preset",
      "persisted": true
    }
  ),
  "presetDropdown": InputField(
    "cs",
    "Checksum",
    "Select",
    {
      "choices": {
        "iso": "ISO 8601"
      },
      "defaultValue": "md2",
      "persisted": true
    }
  ),
  "customStringField": InputField(
    "customString",
    "Custom String",
    "String"
  )
}

// Extensions are implemented as JavaScript classes
var StringFormattedDate = function() {
  // implement the evaluate() method to generate the dynamic value
  this.evaluate = function() {

    if(this.format == "radio-preset") {
      // set inputs to: [
      //   inputFields.choiceRadioButtons,
      //   inputFields.presetDropdown
      // ]
    } else if(this.format == "radio-custom") {
      // set inputs to: [
      //   inputFields.choiceRadioButtons,
      //   inputFields.customStringField
      // ]
    }
    return this.format

    // return moment().format(this.customString);
  }

}

StringFormattedDate.inputs = [
  inputFields.choiceRadioButtons
]

// set the Extension Identifier (must be same as the directory name)
StringFormattedDate.identifier = "com.prtmshk.StringFormattedDate";

// give a display name to your Dynamic Value
StringFormattedDate.title = "String Formatted Date";

// link to the Dynamic Value documentation
// StringFormattedDate.help = "https://luckymarmot.com/paw/doc/";

// call to register function is required
registerDynamicValueClass(StringFormattedDate)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.