pross / bb-rest Goto Github PK
View Code? Open in Web Editor NEWBeaver Builder Rest
Beaver Builder Rest
.class.subclass
is not the same as .class .sublclass
When space is removed, the CSS scope is changing as well.
The REST API call fl-builder/v1/123
returns an object with the properties id
, html
, css
and js
. The two latter are always empty strings. Following implementation of FL_Rest_Content::callback()
works as expected:
static function callback( $request ) {
$post_id = FL_Rest::get_id( $request );
ob_start();
\FLBuilder::render_content_by_id( $post_id );
$output->html = ob_get_clean();
\FLBuilderModel::set_post_id( $post_id );
$output->css = FLBuilder::render_css(false);
$output->js = FLBuilder::render_js(false);
\FLBuilderModel::reset_post_id();
}
FL_Rest::strip_spaces() is intended as "the poor man's" Javascript magnifier; it removes all white spaces in the Javascript. Unfortunately, it can introduce errors.
Some examples how bb-plugin/modules/post-grid/js/frontend.js
is mangled by this method:
The lack of terminating semicolon on line 122 (which is valid JavaScript, although not recommend) creates syntax error when the white space is removed.
return path
on line 160 is mangled to returnpath
which gives syntax error.
The comment on line 215 will after removal of white spaces stretch to the end of the file.
One solution is to replace preg_replace('/[\n\r\t\s]/', '', $txt )
with
preg_replace(["/\s+[\r\n]/", "/[\r\n]\s+/", "/[\t ]+/"], ["\n", "\n ", " "], $txt )
Here is a patch doing just that:
`diff --git a/classes/class-fl-builder-rest.php b/classes/class-fl-builder-rest.php
index 7c294d3..606c119 100644
--- a/classes/class-fl-builder-rest.php
+++ b/classes/class-fl-builder-rest.php
@@ -18,6 +18,6 @@ final class FL_Rest{
}
static function strip_spaces( $txt ) {
- return preg_replace('/[\n\r\t\s]/', '', $txt );
+ return preg_replace(["/\s+[\r\n]/", "/[\r\n]\s+/", "/[\t ]+/"], ["\n", "\n ", " "], $txt );
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.