GithubHelp home page GithubHelp logo

Multiple Extractions about enfocus HOT 5 CLOSED

jacobemcken avatar jacobemcken commented on July 28, 2024
Multiple Extractions

from enfocus.

Comments (5)

ckirkendall avatar ckirkendall commented on July 28, 2024

It might be better just to create a get-attrs extractor that returns a map
of all attrs. I will take a look at it this weekend.

CK

On Fri, Feb 28, 2014 at 8:39 AM, Jacob Emcken [email protected]:

I have a couple of times been wanting to extract multiple attributes from
a node, but since it the function insists on a selector I'm forced to call
from multiple times.

{:name (from a-node (get-attr :name))
:value (from a-node (get-attr :value))
:data-type (from a-node (get-attr :data-type))}

Dunno if it is a good idea, but perhaps something along the lines would
make sense?:

(from a-node
:name nil (get-attr :name)
:value nil (get-attr :value)
:data-type nil (get-attr :data-type))

Reply to this email directly or view it on GitHubhttps://github.com//issues/89
.

from enfocus.

clpe04 avatar clpe04 commented on July 28, 2024

I have a similar issue, but I would like to extract a attribute and the text from a node like this

(from a-node
          :text (get-text)
          :name (get-attr :name))

I was wondering if it was possible to overload the from function, so it could handle either :key selector extractor or just :key extractor, this would prevent the need for giving a nil selector

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

@jacobemcken @clpe04 to do multiple extractions from a single node you can do it like this.

(ns example
    (:require [enfocus.core :refer (get-text this-node get-attr)])
   (:require-marcos [enfocus.macros :refer (from)])

(from a-node
  :text  this-node (get-text)
  :name this-node (get-attr :name))

Hope this helps.

from enfocus.

jacobemcken avatar jacobemcken commented on July 28, 2024

I wasn't aware of the this-node - very pretty solution.
Thanks.

from enfocus.

clpe04 avatar clpe04 commented on July 28, 2024

Thanks for the quick answer, I neither knew about this-node
Your example is very readable and makes perfectly sense together with the sub node form.

from enfocus.

Related Issues (20)

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.